문제

I'm developing a basic simple android application & want the default settings to lead to other activity,

I know this is kinda silly and out topic but I really don't understand how can I default action bar's setting option make lead to my other activity.

enter image description here

The bottom settings option pops up when clicked menu or in some phones on action bar.

도움이 되었습니까?

해결책

You will have to create and start a new activity on the click event of the menu option. In your code, you will have something like this

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.my_menu, menu);
    return true;
}

The above code will inflate the menu XML file. Now, to take some action when an menu option is clicked, you use this code:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.settings:
        //start your activity here
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top