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