如何在Android项目中添加ActionBarActivity?

如何在Android项目中添加ActionBarActivity?,android,project,Android,Project,我无法在我的Android项目中添加ActionBarActivity。在我的任何项目中都没有appcpmpat-v7选项 我现在做什么?在com.android的gradle文件中应该有依赖项。支持:appcompat-v7:21.0.0 并且您输入了有问题的类名。您应该在com.android的gradle文件中具有依赖项。支持:appcompat-v7:21.0.0 并且您输入了有问题的类名。您应该在com.android的gradle文件中具有依赖项。支持:appcompat-v7:21

我无法在我的Android项目中添加ActionBarActivity。在我的任何项目中都没有
appcpmpat-v7
选项


我现在做什么?

在com.android的gradle文件中应该有依赖项。支持:appcompat-v7:21.0.0


并且您输入了有问题的类名。

您应该在com.android的gradle文件中具有依赖项。支持:appcompat-v7:21.0.0


并且您输入了有问题的类名。

您应该在com.android的gradle文件中具有依赖项。支持:appcompat-v7:21.0.0


并且您输入了有问题的类名。

您应该在com.android的gradle文件中具有依赖项。支持:appcompat-v7:21.0.0


您输入了有问题的类的名称。

public class main活动扩展了活动{

@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);
}

}

公共类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);
}

}

公共类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);
}

}

公共类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);
}

}

如果这是一个基于gradle的项目,那么您可以在build.gradle文件中添加以下依赖项,该文件将导入此依赖项

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

PS:23.0.0是针对android M的最新版本。您也可以使用21或22

如果这是一个基于gradle的项目,那么您可以在build.gradle文件中添加以下依赖项,该文件将导入此依赖项

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

PS:23.0.0是针对android M的最新版本。您也可以使用21或22

如果这是一个基于gradle的项目,那么您可以在build.gradle文件中添加以下依赖项,该文件将导入此依赖项

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

PS:23.0.0是针对android M的最新版本。您也可以使用21或22

如果这是一个基于gradle的项目,那么您可以在build.gradle文件中添加以下依赖项,该文件将导入此依赖项

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

PS:23.0.0是针对安卓M的最新版本。您也可以使用21或22
如果您的工作区不包含appcompat,它将由Eclipse自动生成。

您可以在此处找到答案
如果您的工作区不包含appcompat,它将由Eclipse自动生成。

您可以在此处找到答案
如果您的工作区不包含appcompat,它将由Eclipse自动生成。

您可以在此处找到答案 如果您的工作区不包含appcompat,它将由Eclipse自动生成。

您还需要实现“Actionbaractivity”您还需要实现“Actionbaractivity”您还需要实现“Actionbaractivity”您还需要实现“Actionbaractivity”