Note that there are some explanatory texts on larger screens.

plurals
  1. POIntent in ListActivity not working
    text
    copied!<p>I have 1 ListView and 2 buttons in layout.xml file as shown below:</p> <pre><code> &lt;ListView android:id="@android:id/list" android:layout_width="wrap_content" android:layout_height="wrap_content" android:choiceMode="singleChoice"/&gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;Button android:id="@+id/btnBookRoomInRoomselection" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/btnBookRoomInRoomselection" android:width="150dp" /&gt; &lt;Button android:id="@+id/btnCancelInRoomselection" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/btnCancelInRoomselection" android:width="150dp" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>This is my java class:</p> <pre><code>public class RoomSelectionActivity extends ListActivity implements OnClickListener { List&lt;String&gt; bookroom; Button btnBookRoom; Button btnCancel; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.roomselection); bookroom = new ArrayList&lt;String&gt;(); //TODO change the list content from the db bookroom.add("Room1"); bookroom.add("Room2"); bookroom.add("Room3"); bookroom.add("Room4"); btnBookRoom = (Button)findViewById(R.id.btnBookRoomInRoomselection); btnCancel = (Button)findViewById(R.id.btnCancelInRoomselection); setListAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_single_choice, bookroom)); btnBookRoom.setOnClickListener(this); btnCancel.setOnClickListener(this); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.btnBookRoom: Intent bookRoomIntent = new Intent(this,RoomBookedActivity.class); startActivity(bookRoomIntent); break; case R.id.btnCancel: break; } } } </code></pre> <p>When I click the <code>BookRoom</code> button, the intent is not working. I am not sure why this is not working. Please guide me to solve this issue.</p>
 

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