2015-08-31 69 views

回答

0

你應該在你的gradle這個文件com.android.support:appcompat-v7:21.0.0

依賴,並輸入了錯誤的問題類的名稱。

2

公共類MainActivity擴展活動{

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    ActionBar mActionBar = getActionBar(); 
    mActionBar.setDisplayShowHomeEnabled(false); 
    mActionBar.setDisplayShowTitleEnabled(false); 
    LayoutInflater mInflater = LayoutInflater.from(this); 

    View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null); 
    TextView mTitleTextView = (TextView) mCustomView.findViewById(R.id.title_text); 
    mTitleTextView.setText("My Own Title"); 

    ImageButton imageButton = (ImageButton) mCustomView 
      .findViewById(R.id.imageButton); 
    imageButton.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onCl`enter code here`ick(View view) { 
      Toast.makeText(getApplication`enter code here`Context(), "Refresh Clicked!", 
        Toast.LENGTH_LONG).show(); 
     } 
    }); 

    mActionBar.setCustomView(mCustomView); 
    mActionBar.setDisplayShowCustomEnabled(true); 
} 

}

+0

另外你需要實現「Actionbaractivity」 –

1

如果這是一個基於項目的gradle那麼你可以添加在你的build.gradle文件中的以下的依賴,這將導入這種依賴性。

compile 'com.android.support:appcompat-v7:23.0.0' 

PS:23.0.0是最新版本的Android瞄準M.您可以使用21或22,以及

相關問題