Actionbar Tutorials Part 03----Setting custom Icon,Title and Color to the ActionBar

March 27, 2014
output:

MainActivity.java:
package com.example.demo;

import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;

public class MainActivity extends ActionBarActivity {

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

        ActionBar actionBar = getSupportActionBar();

        //setting icon to actionbar
        actionBar.setIcon(R.drawable.spoon);
       
        //setting title to actionbar
        actionBar.setTitle("ActionBar Tutorials");
      
       // setting custom color
        actionBar.setBackgroundDrawable(new ColorDrawable(Color.RED));
    }
}


Artikel Terkait

Previous
Next Post »