Thursday, 27 March 2014

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

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


No comments:

Post a Comment