Mars的mp3实例第一课:
关于menu:
package mars.mp3player01; import mars.down.HttpDownloader; import android.app.ListActivity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.Toast; public class Mp3ListActivity extends ListActivity{ private static final int UPDATE = 3; private static final int ABOUT = 4; @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, 3, 1, R.string.mp3list_update); menu.add(0, 4 , 2,R.string.mp3list_about); return super.onCreateOptionsMenu(menu); } @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); } @Override public boolean onOptionsItemSelected(MenuItem item) { System.out.println("id:"+item.getItemId()); // Intent intent01 = new Intent(this, MainActivity.class); // intent01.s switch (item.getItemId()) { case UPDATE: Mytoast("您选择了更新按钮"); //用户点击了更新列表按钮 break; case ABOUT: Mytoast("您选择了更新关于"); //用户点击了关于按钮 break; } return super.onOptionsItemSelected(item); } private void Mytoast(String message){ Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); } private String downloadXML(){ HttpDownloader httpdownload = new HttpDownloader(); httpdownload.dow return null; } }