我想要 OnListItemClick() 中 Row 的所有视图实际上我想在单击该行时更改其中一个 textView 的文本,因为目前我有两个 textView。我应该调用 OnCreate() 方法还是其他方法?这是代码
public class List extends ListActivity {
public ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.list);
HashMap<String,String> temp = new HashMap<String,String>();
temp.put("first","Strength");
temp.put("second", strength);
list.add(temp);
setListAdapter(new SimpleAdapter(this,list,R.layout.row_view, new String [] {"first","second"}, new int [] {R.id.rowTextView1, R.id.rowTextView2} ));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
HashMap<String,String> temp = new HashMap<String,String>();
list.remove(0);
temp.put("first","Strength");
temp.put("second", "low");
list.add(temp);
Toast.makeText(this, "you have selected " + list.get(position).get("first"), Toast.LENGTH_SHORT).show();
}
}
这是row_view的xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/rowTextView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
/>
<TextView
android:id="@+id/rowTextView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="10dp"
/>
</LinearLayout>
类似地,我想更改 onActivityResult() 中的文本
谢谢