I am displaying a Listview of recorded data and when the user clicks on a specific list item, it triggers an intent and brings the user to the profile for that selected user. I worked when i first ran my project but ever since it just will not work. Thank you in advance.
public class CowListView extends ListActivity {
RegisterCowAdapter cowAdapter;
private DataBaseHelper databaseHelper;
public ListView listView;
TextView student_Id;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cow_list_item);
cowAdapter = new RegisterCowAdapter(this);
cowAdapter.open();
updateCowUI();
listView = (ListView) findViewById(android.R.id.list);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
student_Id = (TextView) view.findViewById(R.id.cowtagnolist);
String studentId = student_Id.getText().toString();
Intent objIndent = new Intent(getApplicationContext(), CowProfile.class);
Toast.makeText(CowListView.this, "Clicked", Toast.LENGTH_SHORT).show();
objIndent.putExtra("student_Id", Integer.parseInt(studentId));
startActivity(objIndent);
}
});
}
private void updateCowUI() {
Cursor cursor = cowAdapter.getAllCowData();
startManagingCursor(cursor);
String[] from = new String[]{RegisterCowAdapter.COWTAGNO, RegisterCowAdapter.COWDOB};
int[] to = new int[]{R.id.cowtagnolist, R.id.cowdoblist};
SimpleCursorAdapter reminders = new SimpleCursorAdapter(
this,
R.layout.cow_list_item,
cursor,
from,
to
);
this.setListAdapter(reminders);
}
}
private void updateCowUI() {
Cursor cursor =cowAdapter.getAllCowData();
startManagingCursor(cursor);
String[] from = new String[]{RegisterCowAdapter.COWTAGNO, RegisterCowAdapter.COWDOB};
int[] to = new int[]{R.id.cowtagnolist, R.id.cowdoblist};
SimpleCursorAdapter reminders = new SimpleCursorAdapter(
this,
R.layout.cow_list_item,
cursor,
from,
to
);
this.setListAdapter(reminders);
}
}
My XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:longClickable="true">
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</ListView>
<TextView
android:id="#+id/cowtagnolist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/black"
android:focusableInTouchMode="false"
android:clickable="false"
android:focusable="false"
android:descendantFocusability="blocksDescendants"
>
</TextView>
<TextView
android:id="#+id/cowdoblist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="17dp"
android:focusableInTouchMode="false"
android:clickable="false"
android:focusable="false"
android:descendantFocusability="blocksDescendants"
android:textColor="#color/black">
</TextView>
</LinearLayout>
Might be one of two things.
You have implemented OnClickListener but you have not set the ListView to listen to that specific class nor have you called any method in your onCreate that will set the ListView's listener to that class.Secondly I think you might need to implement OnItemClickListener and not onCLickListener since thats what is on the ListView, an Item.Im confused though why do you have onClick and then you set the listener inside this method? How will it know in the first place that the view has been clicked if it is not listening from the beginning i.e. in the onCreate or a method called in the onCreate ? Your logic seems abit off
Related
I would like to know if my solution using a ViewBinder is correct and suitable for my problem.
I have implememented a ContentProvider. The startactivity extends ListActivity and displays all the entries from a sqliteDB using my contentprovider. A Click on one of the entries in the listview starts another activity showing detailinformation about this entry:
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// Arzneimittel wurde durch Klick ausgewählt --> Detailansicht anzeigen
Intent intent = new Intent(this, MedikamenteDetailActivity.class);
intent.putExtra("_ID", id);
startActivity(intent);
}
This is the layout of the Detail-Activity:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/txtV_heading_statusinfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/heading_status_info"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ListView
android:id="#+id/datalist"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<TextView
android:id="#+id/txtV_PhZnr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_phznr"
android:text="TextView" />
<TextView
android:id="#+id/txtV_Znr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/znr"
android:text="TextView" />
<TextView
android:id="#+id/txtV_SName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/sname"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/txtV_OName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/oname"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/txtV_DoLC"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/dolc"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
The Detail - Activity Class:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_medikamente_detail);
_id = String.valueOf(getIntent().getExtras().getLong("_ID"));
mAdapter = new SimpleCursorAdapter(
this,
android.R.layout.simple_list_item_1,
null,
mFromColumns,
new int[]{android.R.id.text1},
0);
mCallbacks = this;
ListView mListView = (ListView) findViewById(R.id.datalist);
mAdapter.setViewBinder(new ViewBinder());
mListView.setAdapter(mAdapter);
getLoaderManager().initLoader(URL_LOADER, null, mCallbacks);
}
Within the activity I implemented an inner class for die ViewBinder:
private class ViewBinder implements SimpleCursorAdapter.ViewBinder {
#Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
if(view.getId() == R.id.txtV_PhZnr) {
TextView phznr = (TextView)view;
phznr.setText(cursor.getString(columnIndex));
return true;
}
return false;
}
}
The binding works yet the data is bound to the listview. The other ViewElements stay empty. I can't really understand, why I set the Text of the view "R.id.txtV_PhZnr" and this text appears in the listview-element while the txtV_PhZnr stays empty.
Why do I need a listView-element. As this is a master-detail relationship, only one dataset can be shown in the detail view.
Thank you very much!
Why do I need a listView-element.
No, you do not need one. You can just load the data from your content provider and bind it to the TextViews that you have defined (the ones with ids txtV_xxx). Do this in the onLoadFinished() method.
I can't really understand, why I set the Text of the view "R.id.txtV_PhZnr" and this text appears in the listview-element while the txtV_PhZnr stays empty.
The view parameter passed to setViewValue() method of ViewBinder will only have one of the ids from the array of view ids that you instantiate the SimpleCursorAdapter with. In your case the view parameter will only have the id android.R.id.text1 since the passed-in array contains only this view id. Thus the body of if(view.getId() == R.id.txtV_PhZnr) {...} will never get executed. Hence txtV_PhZnr stays empty.
ViewBinder is used only when you need to alter the binding of data to views based on some condition. As far as your case goes, there is neither a need for a ListView nor a ViewBinder.
I'm having problems with my first Android app.
I have subclassed ListActivity, and I'm having no luck getting the overridden onListItemClick() to respond to click events. I've read focus can be a problem, but changing focus in the XML files does not seem to work. Here's the relevant bits of code. Anyone see what's I've buggered up?
public class Notepadv1 extends ListActivity {
private int mNoteNumber = 1;
private NotesDbAdapter mDbHelper;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.notepad_list);
mDbHelper = new NotesDbAdapter(this);
mDbHelper.open();
fillData();
}
private void fillData() {
// Get all of the notes from the database and create the item list
Cursor c = mDbHelper.fetchAllNotes();
startManagingCursor(c);
String[] from = new String[] { NotesDbAdapter.KEY_TITLE };
int[] to = new int[] { R.id.text1 };
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to);
setListAdapter(notes);
}
#Override
public void onListItemClick (ListView l, View v, int position, long id){
super.onListItemClick(l, v, position, id);
AlertDialog alert = new AlertDialog.Builder(this).create();
String message = "row clicked!";
alert.setMessage(message);
alert.show();
}
notepad_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:dividerHeight="6dp"/>
<TextView android:id="#android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/no_notes" />
</LinearLayout>
And notes_row.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="#+id/text1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:focusable="false"/>
I created a ListActivity, used your onListItemClick, and notes_row.xml. The code works for me. However, I believe you are expecting the entire row to respond to a click, according to notes_row you need to click on the text itself (not anywhere in the row).
Try changing the width attribute in notes_row.xml to "match_parent":
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/text1"
android:layout_height="60dp"
android:layout_width="match_parent"
android:focusable="false" />
Now the entire row responds to user clicks.
Another potential solution in case this helps anyone: I had a Button in each of my list items, and this prevented my onListItemClick event from firing. Replacing the Button with a TextView that looked exactly the same made it work.
Implements OnItemClickListener and do list.setOnItemClickListener.
public class Notepadv1 extends ListActivity implements OnItemClickListener {
onCreate()
{
....
((ListView)findViewById(android.R.id.list)).setOnItemClickListener(this)
}
}
This problem that the listview doesn't show up seems to be very queer. First let me post my codes of functions concerned in activity:
protected ListView mListView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.result);
mListView = (ListView)this.findViewById(R.id.wrdList);
handleIntent(getIntent());
}
private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String word = intent.getStringExtra(SearchManager.QUERY);
//use the query to search your data somehow
//Columns to be selected in database
String sel[] = {"_id", "wort", DictDBHelper.get2LtrLang()};
Cursor SrhRet = mSrhHelper.searchWord(word, sel);
//Columns to be showed in ListView
String col[] = {"wort", DictDBHelper.get2LtrLang()};
showList(SrhRet, col);
SrhRet.close();
} else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
}
}
/*
* Set the TextView to print how many words are found in database
*/
protected void setCount(int count) {
TextView tv = (TextView)this.findViewById(R.id.wrdCount);
tv.setText(String.valueOf(count));
}
/*
* Set the adapter to show the list
* First parameter specifies the cursor of rows to be shown in ListView
* Second one specifies columns
*/
protected void showList(final Cursor SrhRet, String[] from) {
int[] to = new int[]{R.id.entry, R.id.detail};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.listitem, SrhRet, from, to,
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
mListView.setAdapter(adapter);
setCount(mListView.getCount());
mListView.setOnItemClickListener(new OnItemClickListener(){
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Build the Intent used to open WordActivity with a specific word Uri
Intent wordIntent = new Intent(getApplicationContext(), WordActivity.class);
Uri data = Uri.withAppendedPath(DictionaryProvider.ENTRY_CONTENT_URI,
String.valueOf(id));
wordIntent.setData(data);
//Required by the update
SrhRet.close();
mSrhHelper.updateHist(id);
startActivity(wordIntent);
}
});
}
These are functions that handles a input in searchable. I've traced all variables involved but hardly find anything abnormal. However everytime I tried this function the TextView shows the correct numbers that ListView should contain! These functions worked perfectly before and I've another activity derived from this one invokes these functions that works well too.
I use listitem.xml as the contents in ListView's item:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/entry"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textSize="17dp" />
<TextView
android:id="#+id/detail"
android:layout_height="wrap_content"
android:layout_width="match_parent" />
And my result.xml. I've double-checked the orientation.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/wrdCount"
android:layout_height="wrap_content"
android:layout_width="match_parent" />
<ListView
android:id="#+id/wrdList"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
Thanks for help in advance!
I think your problem is the this : SrhRet.close(); in your handleIntent(Intent intent) method.
Please try to close the cursor in the onDestroy() method of the activity.
I am trying to build a simple sms app for which edit page lists all the saved smses. I gave 2 buttons in my layout for Edit and Delete but when I am clicking on them I am unable to get the rowid (row number from top) to retrieve the sms corresponding to that particular row.. Somebody please help me..my sms adapter is not not extending anything..Here's my class and xml files..
public class SMSEdit extends ListActivity{
private SMSDbAdapter mDbHelper;
//private Button editsmsbtn, deletesmsbtn;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.editsmslist);
mDbHelper = new SMSDbAdapter(this);
mDbHelper.open();
fillData();
}
public void fillData() {
Cursor smsCursor = mDbHelper.fetchAllNotes();
startManagingCursor(smsCursor);
// Create an array to specify the fields we want to display in the list (only TITLE)
String[] from = new String[]{SMSDbAdapter.KEY_TITLE,
SMSDbAdapter.KEY_BODY,
SMSDbAdapter.KEY_DATE,
SMSDbAdapter.KEY_TIME};
// and an array of the fields we want to bind those fields to (in this case just text1)
int[] to = new int[]{R.id.smseditlistTO,
R.id.smseditlistMessage,
R.id.smseditlistDay,
R.id.smseditlistTime};
// Now create a simple cursor adapter and set it to display
SimpleCursorAdapter smsadap =
new SimpleCursorAdapter(this, R.layout.smsrow, smsCursor, from, to);
setListAdapter(smsadap);
}
public void myEditClickHandler(View v)
{
//get the row the clicked button is in
LinearLayout vwParentRow = (LinearLayout)v.getParent();
Button btnChild = (Button)vwParentRow.getChildAt(4);
btnChild.setText("I've been clicked!");
ListAdapter pos = getListAdapter();
Intent intent = new Intent();
intent.setClass(SMSEdit.this, SMS.class);
// intent.putExtra(SMSDbAdapter.KEY_ROWID, id);
startActivity(intent);
finish();
}
public void myDeleteClickHandler(View v)
{
//get the row the clicked button is in
LinearLayout vwParentRow = (LinearLayout)v.getParent();
//TextView child = (TextView)vwParentRow.getChildAt(0);
Button btnChild = (Button)vwParentRow.getChildAt(5);
//btnChild.setText(child.getText());
btnChild.setText("I've been clicked!");
int c = Color.CYAN;
vwParentRow.setBackgroundColor(c);
vwParentRow.refreshDrawableState();
}
}
editsmslist.xml -- >>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView android:id="#+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="#+id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Future SMS Yet" android:textSize="35px"/>
</LinearLayout>
smsrow.xml -- >>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="#+id/LinearLayout02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout android:id="#+id/LinearLayout03" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="#string/smsdetailseditlist" android:id="#+id/smseditlistTO" android:paddingLeft="5px">
</TextView>
<TextView android:layout_height="wrap_content" android:text="#string/smsdetailseditlist" android:id="#+id/smseditlistMessage" android:paddingLeft="20px" android:maxLines="1" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:id="#+id/LinearLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" android:paddingLeft="5px">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Date: "></TextView><TextView android:text="#string/smsdetailseditlist" android:id="#+id/smseditlistDay" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Time: " android:paddingLeft="5px"> </TextView><TextView android:text="#string/smsdetailseditlist" android:id="#+id/smseditlistTime" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingRight="10px"></TextView>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="#+id/EditSMSButton" android:text="#string/editsms" android:onClick="#string/myEditClickHandler"></Button>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="#+id/DeleteSMSButton" android:text="#string/deletesms" android:onClick="#string/myDeleteClickHandler"></Button>
</LinearLayout>
</LinearLayout>
</ScrollView>
Also Please suggest if there'a yn better way to implement this or make the layout look better...
You can extend a cursorAdapter like this...
public class exampleAdapter extends CursorAdapter
{
LayoutInflater inflater;
public exampleAdapter (Context context, Cursor c) {
super(context, c);
inflater = LayoutInflater.from(context);
}
#Override
public void bindView(View view, Context context, Cursor cursor) {
// TODO Auto-generated method stub
Button btn_del = (Button)view.findViewById(R.id.button1);
btn_del.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
SMSDbAdapter vb = new SMSDbAdapter(context);
vb.open();
String xyz = cursor.getString(0); //Persumably your ID
vb.Delete(Integer.parseInt(cursor.getString(0)));
Toast.makeText(context, xyz + " Deleted!", Toast.LENGTH_SHORT).show();
vb.close();
}
});
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return inflater.inflate(R.layout.smsrow, parent, false);
}
}
I had a similar problem with my ListView.
Assume you are filling a ListView dynamically. You have 5 rows (for example). The id of first row is 1 second is 2 and so on.
When you scroll whatever rows are visible to you, the id of the 1st row (that you currently see on screen) will always be 1. You need to control that by using mabye some another class (XYZ).
I simply used ArrayList<XYZ> and that worked.
You can override this method in your SMSAdapter:
public View getView(int position, View convertView, ViewGroup parent)
and then call the get(position) method that returns an ArrayList<XYZ>.
You should use ListView to display your messages.
Store the data retrieved from database in a Array of Strings say s1.
Then
private ArrayList<String> arr_sort = new ArrayList<String>();
And copy whole s1 into arr_sort by using add() method.
While setting adapter
lv.setAdapter(new ArrayAdapter<String>(DataAttach.this,
android.R.layout.simple_list_item_1, arr_sort));
where lv is the ListView refernce.
Then use this method for onClick
lv.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String item = (String) lv.getItemAtPosition(position);
Toast.makeText(*.this,
"You selected - " + item + " ,Please wait...",
Toast.LENGTH_LONG).show();
Intent intent = new Intent(*.this, *.class);
*.this.startActivity(intent);
}
});
Hope this helps..
I am using a LinearLayout to display some Text and image. I have the images at drawable/ and i am implimenting this with ListActivity with some onListItemClick functionality. now i wants to change the image for the rows which are processed by onclick functionality to show the status as processed. can some one help me in this issue to change the image at runtime.
the following is my implimentation.
public class ListWithImage extends ListActivity {
/** Called when the activity is first created. */
private SimpleCursorAdapter myAdapter;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// raj setContentView(R.layout.main);
Cursor cursor = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
startManagingCursor(cursor);
String[] columns = new String[] {People.NAME, People.NUMBER};
int[] names = new int[] {R.id.contact_name, R.id.contact_number};
myAdapter = new SimpleCursorAdapter(this, R.layout.main, cursor, columns, names);
setListAdapter(myAdapter);
}
#Override
protected void onListItemClick(ListView listView, View view, int position, long id) {
super.onListItemClick(listView, view, position, id);
Intent intent = new Intent(Intent.ACTION_CALL);
Cursor cursor = (Cursor) myAdapter.getItem(position);
long phoneId = cursor.getLong(cursor.getColumnIndex(People.PRIMARY_PHONE_ID));
intent.setData(ContentUris.withAppendedId(Phones.CONTENT_URI, phoneId));
startActivity(intent);
}
}
and main.xml is :
<LinearLayout
android:layout_height="wrap_content" android:orientation="vertical" android:layout_width="250px">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name: " />
<TextView android:id="#+id/contact_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phone: " />
<TextView android:id="#+id/contact_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
I thought to add the field to DB. but i was unable to know how to change the image with code. can any one provide me an example for drawing image with code and change it based on a condition at runtime.
I've done the same thing in my application (however I didn't use a cursoradapter but a custom adapter, however the logic should be the same).
What I needed to get this working was to include a field in the db which specifies wheater or not the field is processed (or some field deciding which image to show). Then you need to bind your images address to that field. I don't know if you can do this with the simplecursoradapter, or if you need to implement your own though.
Then, when a user clicks an item you just set that item as processed in the db, and you tell your adapter that it has been updated.