samedi 28 mars 2015

How to display the value of an item selected from a list view using textview


Vote count:

0




Using simplesursoradapter I have raised a listview. I select an item from listview and keep it in a variable 'titlename' and able to show in Toast. Now, I want this value in 'titlename' to be passed to a text view id 'textView3' so that it could be displayed on top of the screen in the same activity. When I tried with the following code I get a NULL pointer exception at line textView.setText(v_titlename);.


a)TextView ID 'textView' and 'textView2' are in custom_row.xml


b)TextView ID 'textView3' is in Activity_Out.xml



public void onItemClick(AdapterView<?> parent, View view, int position, long thislist) {
TextView selectedTitle = (TextView)view.findViewById(R.id.textView);
TextView titlename= (TextView)view.findViewById(R.id.textView2);
TextView textView = (TextView) findViewById(R.id.textView3);
v_titlename=titlename.getText().toString();
textView.setText(v_titlename);
Toast.makeText(this, titlename.getText() , Toast.LENGTH_LONG).show();
inputID=selectedTitle.getText().toString(); // the _id of this title is stored in inputID
}


asked 1 min ago







How to display the value of an item selected from a list view using textview

Aucun commentaire:

Enregistrer un commentaire