Up vote 0 down vote favorite share g+ share fb share tw.
This is my code where im fetching the values from database a displaying them in their respective fields I have designed a customlist where I have 5 textviews and 3 buttons My problem is how to make those buttons clickable and I want that row information in the next activity. Cursor = db. RawQuery("SELECT * FROM JOB_LIST_DISPLAY_TABLE",null); adapter = new SimpleCursorAdapter(this,R.layout.
Customlist,cursor, new String {"JOB_TITLE","JOB_START_DATE","JOB_END_DATE","JOB_STATE","JOB_SPECIALITY","JOBPERMANENT",}, new int {R.id. Title,R.id. StartDate,R.id.
EndDate,R.id. State,R.id. Speciality,R.id.
JobType}); listview. SetAdapter(adapter); Each Row in a listview consists these elements Screen looks like below TextView1 Textview2 Textview3 Textview4 Textview5 Button1 Button2 button3 android sqlite listview link|improve this question edited Feb 29 at 14:36 asked Feb 29 at 14:04Girish35 20% accept rate.
1 See one of several prior posts on this: stackoverflow.com/questions/8563915/… – jsmith Feb 29 at 14:08 please let me know the answer – Girish Mar 1 at 10:26.
List. SetOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View view, int position, long id) { } }); where position is row number.
I hope you didn't get my question – Girish Mar 1 at 9:58.
If I have not misunderstood you have to implement onListItemClick that have as parameter position The position of the view in the list then you can you youradapter. GetItem(position) see the doc at: getItem(int).
Im having 5 textviews and 3 buttons in each row like Textview1 – Girish Feb 29 at 14:20.
Listview. SetOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View view, int position, long id) { Log. D("list item position","="+position); /* If you want this position in next activity then put it in bundle extra and start the activity,ten fetch it from bundle in the next activity*/ } }).
In order to catch events from the List items, you're going to have to create a custom Adapter. Within the adapter you'll populate the data in the controls yourself. You can also register for events with those controls.
To tell which row the control is from, you'll need to set the tag on the controls with either the row # or cursor value. You can then get that back from the control when an event is triggered. Here is an example of a custom adapter.
It might point you in the right direction: public class MyAdapter extends ResourceCursorAdapter { private static final class ViewHolder { public TextView mControl1; public TextView mControl2; } private int mData1Col; private int mData2Col; public MyAdapter(Context context, Cursor cursor) { super(context, R.layout. History_entry, cursor, true); // Store cursor column indexes for efficiency. If ( null!
= cursor ) { mData1Col = cursor. GetColumnIndex(DATA1); mData2Col = cursor. GetColumnIndex(DATA2); } } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { // This method creates new views as needed.
Most controls only create // views they need to fill the visible display area, then they re-use them. // Let the parent create the view we specified at construction. View view = super.
NewView(context, cursor, parent); // For efficiency, use a view holder to reference the child views. // These find operations can be expensive so do it just once. ViewHolder vh = new ViewHolder(); vh.
MTitle = (TextView) view. FindViewById(R.id. Control1); vh.
MAt = (TextView) view. FindViewById(R.id. Control2); view.
SetTag(vh); return (view); } @Override public void bindView(View view, Context context, Cursor cursor) { // This methods binds the specified cursor data with the provided view. // Use the ViewHolder to find the controls we need and populate them. ViewHolder vh = (ViewHolder) view.getTag(); // Populate the controls with the current cursor.
// Register to receive events from the controls. // Set the tag on your controls with the cursor position so you // have that info when the item is selected. } @Override public Cursor swapCursor(Cursor newCursor) { // Store column indexes for efficiency.
If (null! = newCursor) { mData1Col = newCursor. GetColumnIndex(DATA1); mData2Col = newCursor.
GetColumnIndex(DATA2); } else { mTitleCol = 0; mResolvedAtCol = 0; } return (super. SwapCursor(newCursor)); } }.
I want each button clickable in a row – Girish Mar 5 at 7:58 plz send full code – Girish Mar 5 at 9:47.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.