Skip to main content
deleted 2 characters in body
Source Link
Eulante
  • 309
  • 2
  • 4
  • 15

This is the code at the moment:

public class PizzeListino extends ActivityTabActivity {   final Context context = this;  @Override  public void onCreate(Bundle SavedIstanceStatesavedInstanceState)  {  { super.onCreate(savedInstanceState);  finaldeleteFile("Ordinazioni.txt");  String[] Secondi = getResources().getStringArraysetContentView(R.arraylayout.pizzeshow_listino); TabHost tabHost = getTabHost();    super.onCreate(SavedIstanceState);//Primi Intent intentPrimi = new setContentViewIntent(R).layoutsetClass(this, Primi.lista_primiclass);   final ListViewTabSpec ListaPrimitabSpecPrimi = (ListView) findViewById(R.id.listView1);tabHost ArrayAdapter<String> arrayAdapter =   .newTabSpec("Primi")  new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, SecondisetIndicator("Primi"); ListaPrimi .setAdaptersetContent(arrayAdapterintentPrimi);   //Secondi  Intent intentSecondi = new ListaPrimiIntent().setOnItemClickListenersetClass(newthis, AdapterViewSecondi.OnItemClickListener(class);  { TabSpec tabSpecSecondi = tabHost @Override.newTabSpec("Secondi") public.setIndicator("Secondi")  void onItemClick(AdapterView<?> adapterView, View Vista, int Posizione, long id) { .setContent(intentSecondi);    // Dolci     StringIntent SelezionatointentDolci = new StringIntent().setClass(this, Dolci.class); TabSpec tabSpecDolci = tabHost  Selezionato = (String) ListaPrimi.getItemAtPositionnewTabSpec(Posizione"Dolci");   Toast.makeText(getApplicationContextsetIndicator("Dolci"),   Selezionato, Toast.LENGTH_SHORT).show();  .setContent(intentDolci);  Selezionato += "\n"; // Pizze     Intent intentPizze = new Intent().setClass(this, Pizze.class); TabSpec tabSpecPizze = tabHost  try {  .newTabSpec("Pizze")  .setIndicator("Pizze")  FileOutputStream fos = openFileOutput("Ordinazioni.txt",Context.MODE_APPEND | Context .MODE_PRIVATEsetContent(intentPizze);      // Bevande     DataOutputStreamIntent dosintentBevande = new DataOutputStreamIntent(fos).setClass(this, Bevande.class);   TabSpec tabSpecBevande = tabHost  dos.writeUTFnewTabSpec(Selezionato"Bevande");   .setIndicator("Bevande")  dos .closesetContent(intentBevande);    // Contorni     }  Intent intentContorni = new Intent().setClass(this, Bevande.class);  catch (Exception e) { TabSpec tabSpecContorni = tabHost e.printStackTracenewTabSpec("Contorni"); }  .setIndicator("Contorni") }  .setContent(intentContorni);    }tabHost.addTab(tabSpecPrimi);  tabHost.addTab(tabSpecSecondi); }tabHost.addTab(tabSpecPizze);  tabHost.addTab(tabSpecDolci);  tabHost.addTab(tabSpecBevande); @Override  } @Override public boolean onCreateOptionsMenu(Menu menu)  {   MenuInflater menuInflater = getMenuInflater();   menuInflater.inflate(R.layoutmenu.opzioni_menu, menu);  return true;  }    public boolean OnOptionsItemSelected(MenuItem item)   {    Toast.makeText(context, item.getItemId(), Toast.LENGTH_SHORT).show();     switch (item.getItemId())   {   case R.id.fineordinazione:   Intent intent = new Intent(context, AggiungiProdotto.class);   startActivity(intent);    return true;  return true;        case R.id.modificaordinazione:   break;     } return false;  return false; }     } }  

}

Aaaw.

This is the code

public class Pizze extends Activity { Context context = this;  @Override  public void onCreate(Bundle SavedIstanceState) { final String[] Secondi = getResources().getStringArray(R.array.pizze); super.onCreate(SavedIstanceState); setContentView(R.layout.lista_primi);   final ListView ListaPrimi = (ListView) findViewById(R.id.listView1); ArrayAdapter<String> arrayAdapter =   new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Secondi); ListaPrimi.setAdapter(arrayAdapter); ListaPrimi.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View Vista, int Posizione, long id) { String Selezionato = new String(); Selezionato = (String) ListaPrimi.getItemAtPosition(Posizione);   Toast.makeText(getApplicationContext(), Selezionato, Toast.LENGTH_SHORT).show();  Selezionato += "\n"; try {  FileOutputStream fos = openFileOutput("Ordinazioni.txt",Context.MODE_APPEND | Context.MODE_PRIVATE);   DataOutputStream dos = new DataOutputStream(fos);   dos.writeUTF(Selezionato); dos.close(); }  catch (Exception e) { e.printStackTrace(); } } }); } @Override public boolean onCreateOptionsMenu(Menu menu)  { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.layout.opzioni_menu, menu); return true;  }    public boolean OnOptionsItemSelected(MenuItem item) { Toast.makeText(context, item.getItemId(), Toast.LENGTH_SHORT).show();     switch (item.getItemId())   {   case R.id.fineordinazione:   Intent intent = new Intent(context, AggiungiProdotto.class);   startActivity(intent); return true;     case R.id.modificaordinazione:   break;     } return false;    } } 

This is the code at the moment:

public class Listino extends TabActivity {   final Context context = this; public void onCreate(Bundle savedInstanceState)  {  super.onCreate(savedInstanceState);  deleteFile("Ordinazioni.txt");  setContentView(R.layout.show_listino); TabHost tabHost = getTabHost();    //Primi Intent intentPrimi = new Intent().setClass(this, Primi.class); TabSpec tabSpecPrimi = tabHost .newTabSpec("Primi")  .setIndicator("Primi")  .setContent(intentPrimi);   //Secondi  Intent intentSecondi = new Intent().setClass(this, Secondi.class);   TabSpec tabSpecSecondi = tabHost .newTabSpec("Secondi") .setIndicator("Secondi")   .setContent(intentSecondi);    // Dolci     Intent intentDolci = new Intent().setClass(this, Dolci.class); TabSpec tabSpecDolci = tabHost  .newTabSpec("Dolci") .setIndicator("Dolci")   .setContent(intentDolci);  // Pizze     Intent intentPizze = new Intent().setClass(this, Pizze.class); TabSpec tabSpecPizze = tabHost  .newTabSpec("Pizze")  .setIndicator("Pizze")   .setContent(intentPizze);    // Bevande     Intent intentBevande = new Intent().setClass(this, Bevande.class); TabSpec tabSpecBevande = tabHost  .newTabSpec("Bevande")   .setIndicator("Bevande")   .setContent(intentBevande);    // Contorni     Intent intentContorni = new Intent().setClass(this, Bevande.class);   TabSpec tabSpecContorni = tabHost .newTabSpec("Contorni")   .setIndicator("Contorni")   .setContent(intentContorni);    tabHost.addTab(tabSpecPrimi);  tabHost.addTab(tabSpecSecondi); tabHost.addTab(tabSpecPizze);  tabHost.addTab(tabSpecDolci);  tabHost.addTab(tabSpecBevande);  } @Override public boolean onCreateOptionsMenu(Menu menu) {   MenuInflater menuInflater = getMenuInflater();   menuInflater.inflate(R.menu.opzioni_menu, menu);  return true; } public boolean OnOptionsItemSelected(MenuItem item)  {    Toast.makeText(context, item.getItemId(), Toast.LENGTH_SHORT).show(); switch (item.getItemId()) { case R.id.fineordinazione: Intent intent = new Intent(context, AggiungiProdotto.class); startActivity(intent);    return true;     case R.id.modificaordinazione: break; } return false;   }    

}

Aaaw.

I have an OptionMenuOptionMenu inside my activityactivity but when I choose an option it shows nothing. I've found some tutorials but they show what I already do. What is wrong? Thank you for the replies.

This is the code (without imports):

I have an OptionMenu inside my activity but when I choose an option it shows nothing. I've found some tutorials but they show what I already do. What is wrong? Thank you for the replies.

This is the code (without imports):

I have an OptionMenu inside my activity but when I choose an option it shows nothing. I've found some tutorials but they show what I already do. What is wrong? Thank you for the replies.

This is the code

public class Pizze extends Activity { Context context = this;  @Override public void onCreate(Bundle SavedIstanceState) { final String[] Secondi = getResources().getStringArray(R.array.pizze); super.onCreate(SavedIstanceState); setContentView(R.layout.lista_primi); final ListView ListaPrimi = (ListView) findViewById(R.id.listView1); ArrayAdapter<String> arrayAdapter =   new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Secondi); ListaPrimi.setAdapter(arrayAdapter);  ListaPrimi.setOnItemClickListener(new AdapterView.OnItemClickListener()  { @Override public void onItemClick(AdapterView<?> adapterView, View Vista, int Posizione, long id)  {    String Selezionato = new String();   Selezionato = (String) ListaPrimi.getItemAtPosition(Posizione);   Toast.makeText(getApplicationContext(), Selezionato, Toast.LENGTH_SHORT).show();   Selezionato += "\n";   try {   FileOutputStream fos = openFileOutput("Ordinazioni.txt",Context.MODE_APPEND | Context.MODE_PRIVATE);   DataOutputStream dos = new DataOutputStream(fos);   dos.writeUTF(Selezionato);   dos.close();   }   catch (Exception e)  {   e.printStackTrace();   }      }  }); } @Override public boolean onCreateOptionsMenu(Menu menu) {   MenuInflater menuInflater = getMenuInflater();   menuInflater.inflate(R.layout.opzioni_menu, menu);   return true; } public boolean OnOptionsItemSelected(MenuItem item)  {     Toast.makeText(context, item.getItemId(), Toast.LENGTH_SHORT).show(); switch (item.getItemId()) { case R.id.fineordinazione: Intent intent = new Intent(context, AggiungiProdotto.class); startActivity(intent);  return true; case R.id.modificaordinazione: break; } return false;  }  } 
public class Pizze extends Activity { Context context = this;  @Override public void onCreate(Bundle SavedIstanceState) { final String[] Secondi = getResources().getStringArray(R.array.pizze); super.onCreate(SavedIstanceState); setContentView(R.layout.lista_primi); final ListView ListaPrimi = (ListView) findViewById(R.id.listView1); ArrayAdapter<String> arrayAdapter =   new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Secondi); ListaPrimi.setAdapter(arrayAdapter);  ListaPrimi.setOnItemClickListener(new AdapterView.OnItemClickListener()  { @Override public void onItemClick(AdapterView<?> adapterView, View Vista, int Posizione, long id)  {    String Selezionato = new String();   Selezionato = (String) ListaPrimi.getItemAtPosition(Posizione);   Toast.makeText(getApplicationContext(), Selezionato, Toast.LENGTH_SHORT).show();   Selezionato += "\n";   try {   FileOutputStream fos = openFileOutput("Ordinazioni.txt",Context.MODE_APPEND | Context.MODE_PRIVATE);   DataOutputStream dos = new DataOutputStream(fos);   dos.writeUTF(Selezionato);   dos.close();   }   catch (Exception e)  {   e.printStackTrace();   }      }  }); } @Override public boolean onCreateOptionsMenu(Menu menu) {   MenuInflater menuInflater = getMenuInflater();   menuInflater.inflate(R.layout.opzioni_menu, menu);   return true; } public boolean OnOptionsItemSelected(MenuItem item)  {     Toast.makeText(context, item.getItemId(), Toast.LENGTH_SHORT).show(); switch (item.getItemId()) { case R.id.fineordinazione: Intent intent = new Intent(context, AggiungiProdotto.class); startActivity(intent);  return true; case R.id.modificaordinazione: break; } return false;  }  } 
public class Pizze extends Activity { Context context = this; @Override public void onCreate(Bundle SavedIstanceState) { final String[] Secondi = getResources().getStringArray(R.array.pizze); super.onCreate(SavedIstanceState); setContentView(R.layout.lista_primi); final ListView ListaPrimi = (ListView) findViewById(R.id.listView1); ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Secondi); ListaPrimi.setAdapter(arrayAdapter); ListaPrimi.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View Vista, int Posizione, long id) { String Selezionato = new String(); Selezionato = (String) ListaPrimi.getItemAtPosition(Posizione); Toast.makeText(getApplicationContext(), Selezionato, Toast.LENGTH_SHORT).show(); Selezionato += "\n"; try { FileOutputStream fos = openFileOutput("Ordinazioni.txt",Context.MODE_APPEND | Context.MODE_PRIVATE); DataOutputStream dos = new DataOutputStream(fos); dos.writeUTF(Selezionato); dos.close(); } catch (Exception e) { e.printStackTrace(); } } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.layout.opzioni_menu, menu); return true; } public boolean OnOptionsItemSelected(MenuItem item) { Toast.makeText(context, item.getItemId(), Toast.LENGTH_SHORT).show(); switch (item.getItemId()) { case R.id.fineordinazione: Intent intent = new Intent(context, AggiungiProdotto.class); startActivity(intent); return true; case R.id.modificaordinazione: break; } return false; } } 
Source Link
Eulante
  • 309
  • 2
  • 4
  • 15
Loading