动作条
让我试着解释一下,我有一个带有可选项的下拉动作栏,主页,联系我们和关于。
请参阅下面的代码:
public class MainActivity extends Activity {
private boolean mNaviFirstHit = true;
….
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SpinnerAdapter sadapter = ArrayAdapter.createFromResource(this, R.array.actions, R.layout.dropdown_textcolor);
// Callback
OnNavigationListener callback = new OnNavigationListener() {
String[] items = getResources().getStringArray(R.array.actions)
@Override
public boolean onNavigationItemSelected(int position, long id) {
if (mNaviFirstHit) {
mNaviFirstHit = false;
return true;
}
if (items[position].equals("Home"))
{
System.out.println("Selected Home");
startActivity(new Intent(getApplicationContext(),MainActivity.class));
}
if (items[position].equals("Contact Us"))
{
System.out.println("Selected Contact US");
startActivity(new Intent(getApplicationContext(),ActionContact.class));
}
if (items[position].equals("About"))
{
System.out.println("Selected About");
startActivity(new Intent(getApplicationContext(),ActionAbout.class));
}