Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>in your CustomAdapter, define a TextView field and a setter for it, then in the onCreate set the textField to the textfield you pulled using findviewbyid</p> <pre><code>MainActivity.java public class MainActivity extends Activity { TextView txt_disp; ListView lv; String fruits[]={"Apple","Orange","Banana","Grapes","kiwi"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); txt_disp=(TextView)findViewById(R.id.textView1); lv=(ListView)findViewById(R.id.listView1); ArrayList&lt;SamplePOJO&gt; searchResults = GetSearchResults(); CustomAdapter ea=new CustomAdapter(this, searchResults); lv.setAdapter(ea); // here i need to set the text(txt_display) ea.setTextField(txt_disp); } } CustomAdapter.java TextView textView; public void setTextField(TextView tv){textView = tv;} enter code here public View getView(final int position, View convertView, ViewGroup parent) { final ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.row1, null); holder = new ViewHolder(); holder.fruit=(TextView) convertView.findViewById(R.id.txt_fruit); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.fruit.setText(ContactArrayList.get(position).getFruit()); holder.fruit.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String dis=holder.fruit.getText().toString(); System.out.println("Selected Text:"+dis); //Selected text value set into textview in MainActivity textView.setText("Selected Text:"+dis); } }); return convertView; } </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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