custom checked listview
I am New to Android. My Requirement is to check an item of lis开发者_运维知识库t view and i want show the selected items in next activity.
can anyone help me..
Refer this to work with listview
Then you can pass that value to you next activity by
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String s = ((TextView) view).getText().toString() ;//get the string
Intent i = new Intent(CurrentActivity.this, NextActivity.class);
i.putExtra("packageName.term", s; //attach you value
startActivity(i); //start activity
}
});
from NextActivity you can read this by
Bundle extras = getIntent().getExtras();
String term = extras.getString("packageName.term"); //read that value
see this example for listView with check-boxes: http://www.marvinlabs.com/2010/10/custom-listview-ability-check-items/
In order to "move" the selected items to the new activity, you can use the traditional way of transferring data between activities - see this: In Android: How do I get variables/data from one screen to another?
or if you want to move a complex object, the most simple way would be to create a singleton object and use it as a "transporter".
精彩评论