Note that there are some explanatory texts on larger screens.

plurals
  1. POListview not showing results
    text
    copied!<p>I am struggling with showing results in a listview. So here is my application in short: </p> <p>First screen -> Different activities to perform and search is one of them. Once User chooses Search, next screen has an input box and two buttons. Based on input keyword, I search for results and want to show results on the next screen, but my next screen appears ,but the results don't appear. Here is some code from my app</p> <pre><code>public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.searchcriteria); txtSearch = (EditText)findViewById(R.id.searchstring); btnCurrentLoc = (Button)findViewById(R.id.currentlocation); btnCurrentLoc.setOnClickListener(new Button.OnClickListener(){ public void onClick(View view){ setContentView(R.layout.searchresults); String keyword = txtSearch.getText().toString(); performSearch(keyword); } }); } private void performSearch(String searchterm){ progressDialog = ProgressDialog.show(Search.this, "Please wait......", "Retrieving data ....",true,true); PerformSearchTask task = new PerformSearchTask(); task.execute(searchterm); progressDialog.setOnCancelListener(new CancelTaskOnCancelListener(task)); } private class PerformSearchTask extends AsyncTask&lt;String, Void, List&lt;Event&gt;&gt;{ @Override protected List&lt;Event&gt; doInBackground(String... arg0) { String query = arg0[0]; return eventGetter.find(query); } protected void onPostExecute(final List&lt;Event&gt; result){ runOnUiThread(new Runnable(){ public void run() { if(progressDialog != null){ progressDialog.dismiss(); progressDialog = null; } if(result != null){ Vector&lt;String&gt; ve = new Vector&lt;String&gt;(); for(Event event: result){ ve.add(event.title + "\n" + event.eventlocation + "\t" + event.eventdate); } String[] eventArray = new String[ve.size()]; for(int i = 0; i &lt; ve.size(); i++){ eventArray[i] = ve.get(i); } ListView lv = (ListView)findViewById(R.id.list); lv.setAdapter(new ArrayAdapter&lt;String&gt;(Search.this,R.layout.searchresults,eventArray)); } } }); } } </code></pre> <p>Searchresults' screen layout is as below</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ScrollView android:id="@+id/resultsofsearch" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;RelativeLayout android:id="@+id/relativelayout_1" android:layout_width="320px" android:layout_height="332px" xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;Button android:id="@+id/back" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Back" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" &gt; &lt;/Button&gt; &lt;Button android:id="@+id/info" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Info" android:layout_alignParentTop="true" android:layout_alignParentRight="true" &gt; &lt;/Button&gt; &lt;ListView android:id="@+id/list" android:layout_width="wrap_content" android:layout_height="0dip" android:layout_weight="1.0" android:layout_below="@+id/back" android:layout_centerHorizontal="true" &gt; &lt;/ListView&gt; &lt;/RelativeLayout&gt; &lt;/ScrollView&gt; </code></pre>
 

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