我有一份案文文件,我正在从我的SD卡中取出,该卡片载有一阵式便衣。 这里是该档案的内容......
http://www.oddree.com/rayhaque/android1.jpg,http://www.oddree.com/rayhaque/android2.jpg,http://www.oddree.com/rayhaque/android3.jpg,http://www.oddree.com/rayhaque/android4.jpg,http://www.oddree.com/rayhaque/android5.jpg
我正试图将这一案文输入一个强硬体,将它变成一个阵列,然后把该阵列装成一个名单改编器。 如果我试图把读写成或读写成一个微不足道的结果,我就会被迫随时关闭。 如果我把档案内容抄录为“长处”,然后使用......一切照旧。
因此,从文字档案中装载这种 st子与从包括舱面上加载两者之间有何区别? 它是一成不变的问题吗?
这里是我的法典。 我注意到了什么是行之有效的,什么是失败的。
public class MainActivity extends Activity {
ListView list;
LazyAdapter adapter;
List<String> strings = new ArrayList<String>();
String readString = new String();
String arrayNBOW;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try{
File f = new File(Environment.getExternalStorageDirectory()+"/LazyList/gkindex.txt");
FileInputStream fileIS = new FileInputStream(f);
BufferedReader buf = new BufferedReader(new InputStreamReader(fileIS));
while((readString = buf.readLine())!= null){
String arrayNBOW = readString.trim();
Toast.makeText(MainActivity.this, "STARTUPPULL: "+arrayNBOW, Toast.LENGTH_LONG).show();
}
} catch (FileNotFoundException e) {
Toast.makeText(MainActivity.this, "FAIL: "+e, Toast.LENGTH_LONG).show();
e.printStackTrace();
} catch (IOException e){
Toast.makeText(MainActivity.this, "FAIL: "+e, Toast.LENGTH_LONG).show();
e.printStackTrace();
}
setContentView(R.layout.main);
list=(ListView)findViewById(R.id.list);
String testArray = "http://www.oddree.com/rayhaque/android1.jpg,http://www.oddree.com/rayhaque/android2.jpg,http://www.oddree.com/rayhaque/android3.jpg";
// THIS FAILS
// String[] testArraySplit = TextUtils.split(arrayNBOW, ",");
// THIS WORKS
String[] testArraySplit = TextUtils.split(testArray, ",");
adapter=new LazyAdapter(this, testArraySplit);
list.setAdapter(adapter);
Button b=(Button)findViewById(R.id.button1);
b.setOnClickListener(listener);
Button c=(Button)findViewById(R.id.button2);
c.setOnClickListener(loadtext);
}
事先感谢你向我提供的任何建议或协助!
www.un.org/Depts/DGACM/index_spanish.htm 禁止使用杀伤人员地雷:
public class MainActivity extends Activity {
ListView list;
LazyAdapter adapter;
List<String> strings = new ArrayList<String>();
String readString = new String();
String arrayNBOW;
String[] nardsArray;
String nards;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/ 新的解决办法
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard,"/LazyList/gkindex.txt");
StringBuilder text = new StringBuilder();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
text.append(line);
text.append(
);
nards = text.toString();
nardsArray = TextUtils.split(nards, ",");
}
}
catch (IOException e) {
Toast.makeText(MainActivity.this, "FAIL: "+e, Toast.LENGTH_LONG).show();
}
/ 最终新解决方案
Toast.makeText(MainActivity.this, "FILE-READ: "+nardsArray, Toast.LENGTH_LONG).show();
setContentView(R.layout.main);
list=(ListView)findViewById(R.id.list);
adapter=new LazyAdapter(this, nardsArray);
list.setAdapter(adapter);
Button b=(Button)findViewById(R.id.button1);
b.setOnClickListener(listener);
Button c=(Button)findViewById(R.id.button2);
c.setOnClickListener(loadtext);
}