Thursday, 19 June 2014

Change the Background Color on an Action Bar

private void actionBar() {
        // remove title
        //    requestWindowFeature(Window.FEATURE_NO_TITLE);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
           
            ActionBar actionBar = getActionBar();
            actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#bdbb35")));
            actionBar.show();
           
            actionBar.setDisplayShowHomeEnabled(false);
            actionBar.setDisplayShowTitleEnabled(false);
            LayoutInflater mInflater = LayoutInflater.from(this);
   
            View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);
           
            //TextView mTitleTextView = (TextView) mCustomView.findViewById(R.id.title_text);
          //  mTitleTextView.setText("My Own Title");
       
            String[] state= {"Andra Pradesh","Arunachal Pradesh","Assam","Bihar","Haryana","Himachal Pradesh", "Jammu and Kashmir", "Jharkhand","Karnataka", "Kerala","Tamil Nadu"};
        /*   
            ArrayAdapter<String> adapter_state = new ArrayAdapter<String>(this,  android.R.layout.simple_spinner_item, state);
            Spinner spinnerGrpuoPractioner=(Spinner) mCustomView.findViewById(R.id.spinner_group_practioner);
           
            spinnerGrpuoPractioner.setAdapter(adapter_state);*/
            actionBar.setCustomView(mCustomView);
            actionBar.setDisplayShowCustomEnabled(true);
           
           
            //http://javatechig.com/android/actionbar-with-custom-view-example-in-android
    }

No comments:

Post a Comment