Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: how do i switch from one activity to another by clicking items from the ListView
    primarykey
    data
    text
    <p>i have made menu list containing play, settings, exit. but clicking the button doesn take me to the desired activity the listner is not working..can any one help me solve the problem.. will b thankfull.. yes its a list view control..</p> <p>there are two errors in my code one is that @@ The type new AdapterView.OnItemClickListener(){} must implement the inherited abstract method AdapterView.OnItemClickListener.onItemClick(AdapterView, View, int, long)@@ in LINE1</p> <p>And the other one is @@ View cannot be resolved to a type@@ in LINE 2 "Actually i want to shift from one screen to another when i click on the item in main menu screen"</p> <p><strong>Here is the code of main menu</strong></p> <pre><code>public class MenuActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.menu); ListView menuList = (ListView) findViewById(R.id.list); String[] items = { getResources().getString(R.string.pla), getResources().getString(R.string.sco), getResources().getString(R.string.set), getResources().getString(R.string.hel), getResources().getString(R.string.qui) }; ArrayAdapter &lt; String &gt; adapt = new ArrayAdapter &lt; String &gt; (this, R.layout.menu_items, items); menuList.setAdapter(adapt); menuList.setOnItemClickListener(new AdapterView.OnItemClickListener() { //LINE 1 error public void onItemClick(AdapterView &lt;? &gt; parent, View itemClicked, //LINE 2 error int position, long id) { TextView textView = (TextView) itemClicked; String strText = textView.getText().toString(); if (strText.equalsIgnoreCase(getResources().getString( R.string.pla))) { // Game startActivity(new Intent(MenuActivity.this, GameActivity.class)); } else if (strText.equalsIgnoreCase(getResources().getString( R.string.hel))) { // Help startActivity(new Intent(MenuActivity.this, HelpActivity.class)); } else if (strText.equalsIgnoreCase(getResources().getString( R.string.set))) { //Settings startActivity(new Intent(MenuActivity.this, SettingsActivity.class)); } else if (strText.equalsIgnoreCase(getResources().getString( R.string.sco))) { // Scores startActivity(new Intent(MenuActivity.this, ScoresActivity.class)); } } }); } } </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.
 

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