Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.prateek.myapp;
- import android.app.ActionBar;
- import android.app.Activity;
- import android.content.res.Resources;
- import android.graphics.Color;
- import android.graphics.drawable.ColorDrawable;
- import android.graphics.drawable.Drawable;
- import android.support.v7.app.ActionBarActivity;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.view.Window;
- public class MainActivity extends Activity {
- ActionBar ab;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- ab = getActionBar();
- ab.setLogo(R.drawable.memorycard);
- ab.setDisplayUseLogoEnabled(false);
- ab.setHomeButtonEnabled(true);
- }
- public void hide_bar(View v){
- ab.setSubtitle("subtitle");
- ab.setTitle("Title");
- Resources r=getResources();
- Drawable draw=r.getDrawable(R.drawable.abc_list_selector_holo_light);
- ab.setBackgroundDrawable(draw);
- ab.setDisplayHomeAsUpEnabled(true);
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.menu_main, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- //noinspection SimplifiableIfStatement
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement