Note that there are some explanatory texts on larger screens.

plurals
  1. POAcessing data form database on click of listView
    primarykey
    data
    text
    <p>I have a ListView in activity1 where I have a few items which are the word from the database . The User Clicks on an item in the Listview and it will navigate to activity2 where it should show the details of the word which are stored in database as column word, definitions . But What appears in Screen2 depends on what item was clicked in Screen 1</p> <p>For Ex - User Clicks A in Screen 1 - Words starting from A come up in Screen 2. Is there any way to pass the row id so that in next screen the word and definition from the database can be displayed.</p> <p>Thank you in adv.. code for first activity:</p> <p>lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {</p> <pre><code> @Override public void onItemClick(AdapterView parent, View v, int position, long id) { // TODO Auto-generated method stub Cursor c = mDictCursor; c.moveToPosition(position); Intent i = new Intent(FirstActivity.this, SecondActivity.class); Bundle bundle=new Bundle(); //intent.putExtra("position",position); bundle.putLong(DBAdapter.KEY_ROWID, id); bundle.putString(DBAdapter.KEY_TITLE, c.getString( c.getColumnIndexOrThrow(DBAdapter.KEY_TITLE))); bundle.putString(DBAdapter.KEY_DEFINITION, c.getString( c.getColumnIndexOrThrow(DBAdapter.KEY_DEFINITION))); i.putExtras(bundle); startActivity(i); } </code></pre> <p>SecondActivity code:</p> <p>Bundle extras = getIntent().getExtras();</p> <pre><code> mRowId = extras.getLong(DBAdapter.KEY_ROWID); String title = extras.getString(DBAdapter.KEY_TITLE); String body = extras.getString(DBAdapter.KEY_DEFINITION); TextView word = (TextView) findViewById(R.id.word); word.setText(title); TextView definition = (TextView) findViewById(R.id.definition); definition.setText(body); } </code></pre> <p>Whenever I am clicking the listview item it is showing dialog to force close. Please help...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload