だからここに私の問題があります。アクションバーのロゴをアクティビティに戻すには、アクションバーをカスタマイズする必要があります。また、ロゴの近くを押してドロップダウンリストを開き、ビューを変更する必要があります。私は何時間も解決策を探しましたが、何も得られませんでした。これはまさに私が取得しようとしているものです:
http://blog.mengto.com/wp-content/uploads/2013/02/android-actionbar.png
私を助けてください!ありがとう
import android.app.Activity;
public class Travel extends Activity {
String[] actions = new String[] { "Gallery View", "Grid View" };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_travel);
// action bar back button
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
/** Create an array adapter to populate dropdownlist */
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
getBaseContext(),
android.R.id.home, actions); //here i am trying to put the home button as the button, but basically i need only the logo to make the back action
/** Enabling dropdown list navigation for the action bar */
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
/** Defining Navigation listener */
ActionBar.OnNavigationListener navigationListener = new OnNavigationListener() {
@Override
public boolean onNavigationItemSelected(int itemPosition,
long itemId) {
Toast.makeText(getBaseContext(),
"This is the: " + actions[itemPosition],
Toast.LENGTH_SHORT).show();
return false;
}
};
/**
* Setting dropdown items and item navigation listener for the actionbar
*
* HERE IS WHERE THE CRASH OCCURS
*/
//getActionBar().setListNavigationCallbacks(adapter, navigationListener);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.travel, menu);
return true;
}
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加