问题描述
StringBuilder ret= new StringBuilder("");
try {
InputStream inputStream =
getApplicationContext().openFileInput("chocolategumballmaker.txt");
if ( inputStream != null ) {
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String receiveString = "";
StringBuilder stringBuilder = new StringBuilder();
while ( (receiveString = bufferedReader.readLine()) != null ) {
stringBuilder.append("\n").append(receiveString);
}
inputStream.close();
ret.append(stringBuilder.toString());
}
}
catch (FileNotFoundException e) {
Toast.makeText(getApplicationContext(),"File not found: " + e.toString(),Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(getApplicationContext(),"Can not read file: " + e.toString(),Toast.LENGTH_LONG).show();
}
while ( ret.toString().startsWith(" ") || ret.toString().startsWith("\n")){
ret.insert(0,"\b");
}
if(ret.toString().trim().equals("red")){
cl.setBackgroundColor(android.R.color.holo_red_dark);
}
if(ret.toString().trim().equals("pink")){
cl.setBackgroundColor(android.R.color.holo_red_light);
}
if(ret.toString().trim().equals("blue")){
cl.setBackgroundColor(android.R.color.holo_blue_dark);
}
如果我运行此代码,背景保持白色。我尝试了更多,如下所示:
i) cl.setBackgroundColor(0xFFFFFF);
ii) cl.setBackgroundColor(Color.parseColor("RED"));
iii) cl.setBackgroundColor(Color.parseColor("#E7EECC"));
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)