For some reason, the standard "Settings" button in the upper right corner disappeared when using ListVu. What is the problem and how to get it back? I will be grateful.
public class MainActivity extends ListActivity { String[] Buttons = new String[100]; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.activity_main); for (int i=0;i<=99;i++){ Buttons[i]=Integer.toString(i+1); } // MyCustomAdapter forData= new MyCustomAdapter(this,Buttons); setListAdapter(new MyCustomAdapter(this,Buttons)); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { Intent intent = new Intent(MainActivity.this,SettingActivity.class); startActivity(intent); return true; } return super.onOptionsItemSelected(item); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Toast.makeText(this, position + " selected", Toast.LENGTH_LONG).show(); } }
setListAdapter(new MyCustomAdapter(this,Buttons));) to the list outside the loop. - JuriySPb ♦