Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.90 KB | None | 0 0
  1. package com.example.prateek.myapp;
  2.  
  3. import android.app.ActionBar;
  4. import android.app.Activity;
  5. import android.content.res.Resources;
  6. import android.graphics.Color;
  7. import android.graphics.drawable.ColorDrawable;
  8. import android.graphics.drawable.Drawable;
  9. import android.support.v7.app.ActionBarActivity;
  10. import android.os.Bundle;
  11. import android.view.Menu;
  12. import android.view.MenuItem;
  13. import android.view.View;
  14. import android.view.Window;
  15.  
  16.  
  17. public class MainActivity extends Activity {
  18.    ActionBar ab;
  19.  
  20.  
  21.     @Override
  22.     protected void onCreate(Bundle savedInstanceState) {
  23.         super.onCreate(savedInstanceState);
  24.         setContentView(R.layout.activity_main);
  25.         ab = getActionBar();
  26.         ab.setLogo(R.drawable.memorycard);
  27.         ab.setDisplayUseLogoEnabled(false);
  28.         ab.setHomeButtonEnabled(true);
  29.     }
  30.  
  31.     public void hide_bar(View v){
  32.  
  33.  
  34.         ab.setSubtitle("subtitle");
  35.         ab.setTitle("Title");
  36.         Resources r=getResources();
  37.         Drawable draw=r.getDrawable(R.drawable.abc_list_selector_holo_light);
  38.         ab.setBackgroundDrawable(draw);
  39.         ab.setDisplayHomeAsUpEnabled(true);
  40.  
  41.  
  42.     }
  43.  
  44.  
  45.  
  46.  
  47.     @Override
  48.     public boolean onCreateOptionsMenu(Menu menu) {
  49.         // Inflate the menu; this adds items to the action bar if it is present.
  50.         getMenuInflater().inflate(R.menu.menu_main, menu);
  51.  
  52.         return true;
  53.     }
  54.  
  55.     @Override
  56.     public boolean onOptionsItemSelected(MenuItem item) {
  57.         // Handle action bar item clicks here. The action bar will
  58.         // automatically handle clicks on the Home/Up button, so long
  59.         // as you specify a parent activity in AndroidManifest.xml.
  60.         int id = item.getItemId();
  61.  
  62.         //noinspection SimplifiableIfStatement
  63.         if (id == R.id.action_settings) {
  64.             return true;
  65.         }
  66.  
  67.         return super.onOptionsItemSelected(item);
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement