Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying List View on Button Click in Android
    primarykey
    data
    text
    <p>I am creating an android application in which there are two activites. One activity contains a button. On the button click, i want to switch to other activity which displays a list view containing few options.</p> <p>Two switch between the screens or activities , i am using the following code</p> <pre><code>Intent intent = new Intent(Activity1.this,Activity2.class); startActivity(intent); </code></pre> <p>Since my Activity2 class extends the 'ListActivity', this code doesn't seem to work. On my button click, i want to display a list view containing some data.</p> <p>Any help would be appreciated</p> <p>@Siddharth i seem to be doing almost the same thing Here is my actual code</p> <p>From Activity 1</p> <pre><code>public void onClick(View v) { Intent intent = new Intent(View_Data.this,CategoryList.class); startActivity(intent); } </code></pre> <p>In Activity 2</p> <pre><code>public class CategoryList extends ListActivity { public TextView selection; public String[] categories; ArrayList&lt;String&gt; type_of_category; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.category_list); getCategories(); } public void getCategories() { DBHelper dbhelper = new DBHelper(this); type_of_category = new ArrayList&lt;String&gt;(); type_of_category = dbhelper.getTypesOfQuotes(); String[] items = new String[100]; for(int i=0;i&lt;type_of_type_of_category.size();i++) { items[i] = type_of_type_of_category.get(i); } setListAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,items)); } </code></pre> <p>}</p> <p>Here is my XML File</p> <pre><code> &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" &gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>In My 2nd Activity, i get the error in this line</p> <pre><code> setContentView(R.layout.category_list); </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.
 

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