TakeThat
TakeThat

Reputation: 41

actionbar support v7 android

IDE: Android Studio

  1. Create new project
  2. Copy .jar of appcompat to by /lib/
  3. Set dependencies in project settins
  4. Add compile "com.android.support:appcompat-v7:18.0.+" to build.gradle
  5. Add follow code:

    public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        ActionBar actionBar = getSupportActionBar();
        actionBar.setTitle("hello");
    }
    

AND... Nothing. Get next error:

"Gradle: A problem occurred configuring project ':MyApplication'.
> Failed to notify project evaluation listener.   > Could not resolve all dependencies for configuration ':MyApplication:_DebugCompile'.
  > Could not find any version that matches com.android.support:appcompat-v7:18.0.+.
    Required by:
        MyApplicationProject:MyApplication:unspecified"

How to fix? What i forget to do?

Upvotes: 4

Views: 4909

Answers (2)

user3439576
user3439576

Reputation: 1

Try importing the the library instead of copying it.

Also include:

actionBar.setDisplayShowTitleEnabled(true);

Upvotes: 0

Vivart
Vivart

Reputation: 15313

you need to install the support repository

3.Select the Android Support Library item.

Note: If you're developing with Android Studio, select and install the Android Support Repository item instead. http://developer.android.com/tools/support-library/setup.html

Upvotes: 7

Related Questions