Android 填充Listview使我的其他参数为空
我正在用upload button click填充一个数组,并在listview中查看它们,但问题是,在单击upload button之后,它会使同一活动中的其他值变为空,即使微调器值也变为空 这是我的上传按钮点击代码Android 填充Listview使我的其他参数为空,android,listview,buttonclick,Android,Listview,Buttonclick,我正在用upload button click填充一个数组,并在listview中查看它们,但问题是,在单击upload button之后,它会使同一活动中的其他值变为空,即使微调器值也变为空 这是我的上传按钮点击代码 public void uploadfile(View view){ edittext = (EditText)findViewById(R.id.txtFile); List<String> name = new Ar
public void uploadfile(View view){
edittext = (EditText)findViewById(R.id.txtFile);
List<String> name = new ArrayList<String>();
List<String> number = new ArrayList<String>();
List<String> status = new ArrayList<String>();
if(FullPath != null)
{
// CSV UPLOADER
try{
File csvfile = new File(FullPath);
FileInputStream csvStream = new FileInputStream(csvfile);
BufferedReader in = new BufferedReader(new InputStreamReader(csvStream));
String[] rowData = null;
String dataRow = in.readLine();
while (dataRow != null){
String[] RowData = dataRow.split(",");
name.add(new String(RowData[0]));
number.add(new String(RowData[1]));
status.add("unsent");
dataRow = in.readLine();
}
in.close();
Toast.makeText(NewMessage.this, "CSV Has uploaded", 2000).show();
setContentView(R.layout.new_message);
}
catch(Exception e)
{
Toast.makeText(NewMessage.this, e.toString(), 2000).show();
}
//CSV Uploaded
//View CSV into an array
try{
setContentView(R.layout.new_message);
ListView lv = (ListView)findViewById(R.id.lv);
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
for(int i=0;i<name.size();i++)
{
HashMap<String, String> map = new HashMap<String, String>();
map.put("name",name.get(i));
map.put("number",number.get(i));
map.put("status",status.get(i));
mylist.add(map);
}
SimpleAdapter mSchedule = new SimpleAdapter(NewMessage.this, mylist, R.layout.view_csv, new String[] {"name","number","status"}, new int[] {R.id.t1,R.id.t2,R.id.t3});
lv.setAdapter(mSchedule);
}
catch(Exception e){
Toast.makeText(NewMessage.this, e.toString(), 2000).show();
}
//Viewing Finish Here
}
else
{
Toast.makeText(NewMessage.this, "No File Selected", 2000).show();
}
}
public void上传文件(视图){
edittext=(edittext)findViewById(R.id.txtFile);
列表名称=新的ArrayList();
列表编号=新的ArrayList();
列表状态=新建ArrayList();
if(完整路径!=null)
{
//CSV上传器
试一试{
文件csvfile=新文件(完整路径);
FileInputStream csvStream=新的FileInputStream(csvfile);
BufferedReader in=新的BufferedReader(新的InputStreamReader(csvStream));
字符串[]rowData=null;
字符串dataRow=in.readLine();
while(dataRow!=null){
字符串[]RowData=dataRow.split(“,”);
name.add(新字符串(RowData[0]);
添加(新字符串(RowData[1]);
状态。添加(“未发送”);
dataRow=in.readLine();
}
in.close();
Toast.makeText(NewMessage.this,“CSV已上传”,2000).show();
setContentView(R.layout.new_消息);
}
捕获(例外e)
{
Toast.makeText(NewMessage.this,例如toString(),2000).show();
}
//CSV上传
//将CSV查看到一个数组中
试一试{
setContentView(R.layout.new_消息);
ListView lv=(ListView)findViewById(R.id.lv);
ArrayList mylist=新的ArrayList();
对于(int i=0;调用setContentView(R.layout.new_message);
替换活动的整个布局。这就是你的意思吗?好的,让我检查一下,这就是我想要的,非常感谢你:)。Frustation导致:P