Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can do something like this</p> <pre><code>public class Mainactivity extends Activity{ ListView listView; EfficientAdapter objectAdapter; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.mainlayout); listView = (ListView) findViewById(R.id.homelistView); listView.setTextFilterEnabled(true); objectAdapter = new EfficientAdapter(this); listView.setAdapter(objectAdapter); Button refreshButton= (Button)findViewById(R.id.refreshButton); refreshButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { objectAdapter = new EfficientAdapter(Mainactivity.this);// adapter with new data listView.setAdapter(objectAdapter); objectAdapter.notifyDataSetChanged(); } }); } } </code></pre> <p>This is a sample of what I want to tell you:</p> <pre><code>public class second extends Activity{ ListView listView; ArrayAdapter&lt;String&gt; adapter; Button button; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.second); listView=(ListView) findViewById(R.id.listView1); button=(Button) findViewById(R.id.button1); String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"}; ArrayList&lt;String&gt; planetList = new ArrayList&lt;String&gt;(); planetList.addAll( Arrays.asList(planets) ); // Create ArrayAdapter using the planet list. adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.simplerow, planetList); listView.setAdapter(adapter); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String[] planets = new String[] { "Mercury m", "Venus m", "Earth m", "Mars m", "Jupiter m", "Saturn m", "Uranus m", "Neptune m"}; ArrayList&lt;String&gt; planetList = new ArrayList&lt;String&gt;(); planetList.addAll( Arrays.asList(planets) ); adapter = new ArrayAdapter&lt;String&gt;(second.this, R.layout.simplerow, planetList); listView.setAdapter(adapter); adapter.notifyDataSetChanged(); } }); } } </code></pre> <p>Where R.layout.simplerow:</p> <pre><code>&lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rowTextView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="10dp" android:textSize="16sp" &gt; &lt;/TextView&gt; </code></pre> <p>and R.layout.second:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;ListView android:id="@+id/listView1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" &gt; &lt;/ListView&gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /&gt; &lt;/RelativeLayout&gt; </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. 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.
 

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