示例#1
0
  // Comportement de la partie search dans l'appBar
  protected void handleMenuSearch() {
    ActionBar action = getSupportActionBar(); // get the actionbar

    if (isSearchOpened) { // test if the search is open

      action.setDisplayShowCustomEnabled(false); // disable a custom view inside the actionbar
      action.setDisplayShowTitleEnabled(true); // show the title in the action bar

      // hides the keyboard
      InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(edtSeach.getWindowToken(), 0);

      // add the search icon in the action bar
      mSearchAction.setIcon(getResources().getDrawable(R.drawable.ic_menu_search));

      isSearchOpened = false;
    } else { // open the search entry

      action.setDisplayShowCustomEnabled(true); // enable it to display a
      // custom view in the action bar.
      action.setCustomView(R.layout.search_bar); // add the custom view
      action.setDisplayShowTitleEnabled(false); // hide the title

      edtSeach =
          (EditText)
              action.getCustomView().findViewById(R.id.searchBar_editText); // the text editor

      // this is a listener to do a search when the user clicks on search button
      edtSeach.setOnEditorActionListener(
          new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
              if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                doSearch();
                return true;
              }
              return false;
            }
          });

      edtSeach.requestFocus();

      // open the keyboard focused in the edtSearch
      InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.showSoftInput(edtSeach, InputMethodManager.SHOW_IMPLICIT);

      // add the close icon
      mSearchAction.setIcon(getResources().getDrawable(R.drawable.ic_menu_search));

      isSearchOpened = true;
    }
  }
示例#2
0
 public void restoreActionBar() {
   ActionBar actionBar = getSupportActionBar();
   if (mSelectPos != 2) {
     mTitle = mMainTitles[mSelectPos];
     actionBar.setDisplayShowCustomEnabled(false);
     actionBar.setDisplayShowTitleEnabled(true);
     actionBar.setTitle(mTitle);
   } else {
     actionBar.setDisplayShowCustomEnabled(true);
     actionBar.setCustomView(mActionbarCustom);
     actionBar.setTitle("");
   }
 }
示例#3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_file_view);
    Intent intent = getIntent();
    subN = intent.getExtras().getString("subn");
    tt = intent.getExtras().getString("tt");

    arrayList_path = new ArrayList<String>();
    arrayList_time = new ArrayList<String>();
    arrayList_filecode = new ArrayList<String>();

    file_list = (ListView) findViewById(R.id.list_file);

    adapterFile = new CustomAdapterFile();

    final android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowHomeEnabled(true);
    // actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setHomeAsUpIndicator(R.drawable.btnback);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(R.layout.actionbar_layout);
    // actionBar.setLogo(R.drawable.btnback);

    TextView txt_subn = (TextView) findViewById(R.id.txt_actionbar);
    txt_subn.setText(subN);

    // Toast.makeText(getApplicationContext(),tt,Toast.LENGTH_SHORT).show();

    net = new Net();
    net.execute();
  }
    @Override
    public void applySelfActionBar() {
        if (parentActivity == null) {
            return;
        }
        ActionBar actionBar = parentActivity.getSupportActionBar();
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setSubtitle(null);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayUseLogoEnabled(false);
        actionBar.setDisplayShowCustomEnabled(false);
        actionBar.setCustomView(null);
        actionBar.setTitle(getStringEntry(R.string.NotificationsAndSounds));

        TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
        if (title == null) {
            final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
            title = (TextView)parentActivity.findViewById(subtitleId);
        }
        if (title != null) {
            title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
            title.setCompoundDrawablePadding(0);
        }
    }
  private void initTitleBar() {
    mSpinnerAdapter = new MySpinnerAdapter(getLayoutInflater());

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ActionBar supportActionBar = getSupportActionBar();
    supportActionBar.setDisplayHomeAsUpEnabled(true);
    supportActionBar.setDisplayShowHomeEnabled(true);
    supportActionBar.setHomeButtonEnabled(true);
    supportActionBar.setTitle("");
    supportActionBar.setDisplayShowCustomEnabled(true);

    supportActionBar.setCustomView(R.layout.actionbar_custom_spinner);
    Spinner spinner = (Spinner) supportActionBar.getCustomView().findViewById(R.id.spinner);
    spinner.setAdapter(mSpinnerAdapter);
    spinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            mSpinnerAdapter.setCheckPos(position);
            changePageShow(position);
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
  }
  @Override
  public void applySelfActionBar() {
    if (parentActivity == null) {
      return;
    }
    ActionBar actionBar = parentActivity.getSupportActionBar();
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(false);

    actionBar.setCustomView(R.layout.settings_do_action_layout);
    View cancelButton = actionBar.getCustomView().findViewById(R.id.cancel_button);
    cancelButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            finishFragment();
          }
        });
    doneButton = actionBar.getCustomView().findViewById(R.id.done_button);
    doneButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (firstNameField.getText().length() != 0) {
              saveName();
              finishFragment();
            }
          }
        });
  }
示例#7
0
  public void onCreate(Bundle savedInstanceState) {
    if (Utils.isTablet(this)) {
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.firstrun);
    context = this;
    Utils.showWhatNewDialog(context);
    ActionBar actionBar = getSupportActionBar();
    TextView ganjdroid = new TextView(this);
    Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/font3.ttf");
    ganjdroid.setTypeface(typeface);
    ganjdroid.setText("GrowDroid");
    ganjdroid.setTextSize(20);
    ganjdroid.setGravity(Gravity.CENTER);
    ganjdroid.setTextColor(getResources().getColor(R.color.white));
    actionBar.setCustomView(ganjdroid);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setLogo(getResources().getDrawable(R.drawable.ic_launcher));

    TextView textView = (TextView) findViewById(R.id.pressTextView);
    textView.setTypeface(
        Typeface.createFromAsset(context.getAssets(), "fonts/Roboto/Roboto-Thin.ttf"));
    RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.pressLayout);
    relativeLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent intent = new Intent(context, NewCycle.class);
            startActivity(intent);
          }
        });
  }
 private void setUpActionBar() {
   ActionBar mActionBar = getSupportActionBar();
   mActionBar.setDisplayShowHomeEnabled(false);
   mActionBar.setDisplayShowTitleEnabled(true);
   mActionBar.setDisplayHomeAsUpEnabled(true);
   mActionBar.setHomeButtonEnabled(true);
   mActionBar.setDisplayShowCustomEnabled(true);
 }
示例#9
0
  private void onSpinnerSelected() {
    ActionBar actionBar = getSupportActionBar();
    Spinner spinner;
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(mActionbarCustom);
    actionBar.setTitle("");
    spinner = (Spinner) mActionbarCustom.findViewById(R.id.spinner);

    boolean containFragment = false;
    if (!containFragment) {
      int pos = spinner.getSelectedItemPosition();
      spinner.getOnItemSelectedListener().onItemSelected(null, null, pos, pos);
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bpm_sort_list_activity_main);

    // 得到父Activity的参数
    Intent intent = getIntent();
    multichoice = intent.getBooleanExtra("multichoice", false);
    indexList = intent.getIntegerArrayListExtra("indexList");
    TYPE = intent.getIntExtra("type", TYPE_NORMAL);

    // 初始化actionbar
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(false);
    View customView = getLayoutInflater().inflate(R.layout.bpm_title, null);
    actionBar.setCustomView(customView);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);

    ((TextView) findViewById(R.id.title)).setText(intent.getStringExtra("title"));

    if (multichoice) {
      ((TextView) findViewById(R.id.button_ok)).setText("确定");

      findViewById(R.id.button_ok)
          .setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                  Intent intent = new Intent();
                  intent.putExtra("data", getMultiChoice());

                  setResult(RESULT_OK, intent);
                  finish();
                }
              });
    } else findViewById(R.id.button_ok).setVisibility(View.INVISIBLE);

    findViewById(R.id.imageButton_back)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                setResult(RESULT_CANCELED);
                finish();
              }
            });

    initViews();
  }
示例#11
0
  private void initToolbar() {
    // 액션바 객체 생성
    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    // 액션바 설정
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);
    // 액션바 숨김
    actionBar.hide();

    // 툴바 설정
    mToolBar = (Toolbar) findViewById(R.id.main_toolbar);
    mToolBar.setContentInsetsAbsolute(0, 0);
  }
 private void setUpToolBar() {
   mToolBar = (Toolbar) findViewById(R.id.toolbar_business_des);
   if (mToolBar != null) {
     setSupportActionBar(mToolBar);
     ActionBar actionBar = getSupportActionBar();
     actionBar.setDisplayShowTitleEnabled(false);
     LayoutInflater inflater = LayoutInflater.from(this);
     View view = inflater.inflate(R.layout.custom_action_bar, null, true);
     actionBar.setCustomView(view);
     actionBar.setDisplayShowCustomEnabled(true);
     actionBar.setHomeAsUpIndicator(R.drawable.backarrow);
     actionBar.setDisplayHomeAsUpEnabled(true);
   }
 }
  public void init(Context context, ActionBar actionBar) {

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View layout = inflater.inflate(R.layout.action_bar_layout, null);

    // Set up ActionBar
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);

    actionBar.setCustomView(layout);
    int actionBarColor = context.getResources().getColor(R.color.violet);
    actionBar.setBackgroundDrawable(new ColorDrawable(actionBarColor));
  }
示例#14
0
 /** 设置actionbar */
 public void setActionBar() {
   ActionBar actionbar = this.getSupportActionBar();
   actionbar.setDisplayHomeAsUpEnabled(true);
   actionbar.setDisplayShowCustomEnabled(true);
   actionbar.setDisplayShowTitleEnabled(true);
   View v = this.getLayoutInflater().inflate(R.layout.actionbar_bbs_newtheme, null);
   ActionBar.LayoutParams param = new ActionBar.LayoutParams(Gravity.RIGHT);
   actionbar.setCustomView(v, param);
   View okv = v.findViewById(R.id.actionbar_ok);
   okv.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           if (adminId != UserPreUtil.getUserid() && hasjoin != true)
             Toast.makeText(Community.this, "你还没有加入该社区", Toast.LENGTH_SHORT).show();
           else NewThemeActivity.startAction(Community.this, communityid);
         }
       });
 }
示例#15
0
 /**
  * 为Fragment设置ActionBar
  *
  * @param VIEWVISIBILITY visible.
  */
 private void initActionbarByFragment(int VIEWVISIBILITY) {
   View actionBarView = View.inflate(this, R.layout.custom_actionbar, null);
   // 初始化ActionBar的样式
   ActionBar actionBar = getSupportActionBar();
   actionBar.setCustomView(actionBarView);
   actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
   actionBar.setDisplayShowCustomEnabled(true);
   // END.
   actionBarTools = (Button) actionBarView.findViewById(R.id.btn_actionbar_showtools);
   actionBarTools.setVisibility(VIEWVISIBILITY);
   if (VIEWVISIBILITY == View.VISIBLE) {
     actionBarTools = (Button) actionBarView.findViewById(R.id.btn_actionbar_showtools);
     actionBarTools.setOnClickListener(this);
   }
   if (seeFragment == null) {
     seeFragment = new SeeFragment();
   }
   actionBarView.setOnClickListener(seeFragment.new SeeLvReturnTop());
 }
  private ActionBar setupActionbar() {
    ActionBar actionBar = getSupportActionBar();

    View view = mActionBarView = getLayoutInflater().inflate(R.layout.action_bar_layout, null);

    if (actionBar != null) {
      actionBar.setDisplayShowHomeEnabled(false);
      actionBar.setDisplayShowCustomEnabled(true);
      actionBar.setDisplayShowTitleEnabled(false);
      ActionBar.LayoutParams layoutParams =
          new ActionBar.LayoutParams(
              ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT);
      actionBar.setCustomView(view, layoutParams);
    }

    Toolbar parent = (Toolbar) view.getParent();
    parent.setContentInsetsAbsolute(0, 0);
    return actionBar;
  }
示例#17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    View view = getLayoutInflater().inflate(R.layout.action_bar_view, null);
    view.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    TextView titleView = (TextView) view.findViewById(R.id.title_text);
    titleView.setText(R.string.actionBar_title);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      actionBar.setElevation(0);
      actionBar.setCustomView(view);
      actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#ffffff")));
      actionBar.setDisplayShowCustomEnabled(true);
    }

    firstNameEditView = (EditText) findViewById(R.id.firstName);
    lastNameEditView = (EditText) findViewById(R.id.lastName);
    emailIdEditView = (EditText) findViewById(R.id.email);
    cityEditView = (EditText) findViewById(R.id.city);
    zipEditView = (EditText) findViewById(R.id.zip);
    next = (Button) findViewById(R.id.next);

    stateSpinner = (Spinner) findViewById(R.id.state);

    // Edit Text view click Time only open the keyboard
    InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mgr.hideSoftInputFromWindow(firstNameEditView.getWindowToken(), 0);
    mgr.hideSoftInputFromWindow(lastNameEditView.getWindowToken(), 0);
    mgr.hideSoftInputFromWindow(emailIdEditView.getWindowToken(), 0);
    mgr.hideSoftInputFromWindow(cityEditView.getWindowToken(), 0);
    mgr.hideSoftInputFromWindow(zipEditView.getWindowToken(), 0);
    mgr.showSoftInput(firstNameEditView, InputMethodManager.SHOW_IMPLICIT);
    mgr.showSoftInput(lastNameEditView, InputMethodManager.SHOW_IMPLICIT);
    mgr.showSoftInput(emailIdEditView, InputMethodManager.SHOW_IMPLICIT);
    mgr.showSoftInput(cityEditView, InputMethodManager.SHOW_IMPLICIT);
    mgr.showSoftInput(zipEditView, InputMethodManager.SHOW_IMPLICIT);

    boolean tabletSize = getResources().getBoolean(R.bool.isTablet);
    if (tabletSize) {
      stateDetail =
          new String[] {
            "AZ", "NY", "AL", "AK", "AR", "CA", "CO", "CT", "DC", "DE", "FL", "GA", "HI", "ID",
            "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT",
            "NE", "NV", "NH", "NJ", "NM", "NC", "ND", "OH", "OK", "OR", "PA", "PR", "RI", "SC",
            "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"
          };

    } else {
      specialtySpinner = (Spinner) findViewById(R.id.specialty);
      String[] specialtyItem =
          new String[] {
            "Pulmonologist",
            "Cardiologist",
            "Hematologist",
            "Rheumatologist",
            "Infectious Disease",
            "Other"
          };
      ArrayAdapter<String> adapter =
          new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, specialtyItem);
      specialtySpinner.setAdapter(adapter);
      stateDetail =
          new String[] {
            "NY", "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DC", "DE", "FL", "GA", "HI", "ID",
            "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT",
            "NE", "NV", "NH", "NJ", "NM", "NC", "ND", "OH", "OK", "OR", "PA", "PR", "RI", "SC",
            "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"
          };
    }

    ArrayAdapter<String> stateAdapter =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_spinner_item, stateDetail); // State = AZ(tab)

    stateSpinner.setAdapter(stateAdapter);

    next.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            validateRegisterInfo();
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_waiting_for_sherpa);
    ActionBar mActionBar = getSupportActionBar();
    mActionBar.setDisplayShowHomeEnabled(false);
    mActionBar.setDisplayShowTitleEnabled(false);

    LayoutInflater mInflater = LayoutInflater.from(this);

    View mCustumView = mInflater.inflate(R.layout.menu_action_bar, null);
    ((Button) mCustumView.findViewById(R.id.show_menu_ma))
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                System.out.println("mostrar el creado desde el main.");
                is_overlay_shown++;
                overlayIntent = new Intent(v.getContext(), OverlayActivity.class);
                overlayIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                overlayIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

                overlayIntent.putExtra("code", OverlayActivity.SHOW_MENU);

                startActivityForResult(overlayIntent, CONSTANTS.MENU_OPTION);
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left);
              }
            });
    mActionBar.setCustomView(mCustumView);
    mActionBar.setDisplayShowCustomEnabled(true);

    h = new Handler();
    r =
        new Runnable() {

          @Override
          public void run() {
            isServiceAttended();
          }
        };

    ImageView loading = (ImageView) findViewById(R.id.imageView1);
    loading.setBackgroundResource(R.drawable.loading_animation);
    loadingAnimation = (AnimationDrawable) loading.getBackground();
    loadingAnimation.start();

    // destinations = this.getIntent().getParcelableExtra(CONSTANTS.DESTINATIONS_NAME);

    SharedPreferences settings =
        this.getSharedPreferences("com.fr3estudio.sherpaV3P.UsersData", Context.MODE_PRIVATE);

    String data = settings.getString(CONSTANTS.DESTINATIONS_NAME, "");

    try {
      destinations = (ArrayList<Destination>) ObjectSerializer.deserialize(data);
    } catch (IOException e) {
      e.printStackTrace();
      showDialog(
          getResources().getString(R.string.msg_savingData_title),
          getResources().getString(R.string.msg_detail_internal),
          false,
          false);
      destinations = new ArrayList<>();
    }
    Log.i("Waiting", "se cargaron: " + destinations.size() + " destinos");

    insert_service = this.getIntent().getBooleanExtra(CONSTANTS.INSERT_SERVICE, false);
    id_cliente = this.getIntent().getIntExtra(CONSTANTS.ID_CLIENT, 0);
    if (insert_service) {
      insertServiceRequest();
    } else {
      service_id = this.getIntent().getIntExtra(CONSTANTS.ID_SERVICE, 0);
      scheduleAttentionQuery(0);
    }
  }
示例#19
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    overridePendingTransition(0, 0);

    FacebookSdk.sdkInitialize(getApplicationContext());

    firstLogin();

    user_db = new SQLiteHandler(getApplicationContext());

    // session manager
    session = new SessionManager(getApplicationContext());
    layout = (RelativeLayout) findViewById(R.id.layout);

    // Set the size-parameters for the different elements of the layout
    height = getResources().getDimensionPixelSize(R.dimen.section_height);
    width = RelativeLayout.LayoutParams.MATCH_PARENT;
    dateWidth = getResources().getDimensionPixelSize(R.dimen.date_width);
    divHeight = getResources().getDimensionPixelSize(R.dimen.div_height);

    // Load the custom fonts
    lobster = Typeface.createFromAsset(getAssets(), "lobster.otf");
    express = Typeface.createFromAsset(getAssets(), "expressway.ttf");

    // Set the ProgressDialog
    pDialog = new ProgressDialog(this);
    pDialog.setCancelable(false);

    first = true;

    // Logout users that aren't supposed to be here
    if (AccessToken.getCurrentAccessToken() == null
        && !session.isLoggedIn()
        && !user_db.getUserDetails().isEmpty()) {
      logoutUser();
    }

    // Get UID
    uid = user_db.getUserDetails().get("email");

    // Set the ActionBar

    ActionBar mActionBar = getSupportActionBar();
    mActionBar.setDisplayShowHomeEnabled(false);
    mActionBar.setDisplayShowTitleEnabled(false);
    LayoutInflater mInflater = LayoutInflater.from(this);
    View mCustomView = mInflater.inflate(R.layout.actionbar_main, null);

    mActionBar.setCustomView(mCustomView);
    mActionBar.setDisplayShowCustomEnabled(true);

    TextView txt = (TextView) findViewById(R.id.title_text);
    txt.setTypeface(lobster);
    txt.setText(R.string.app_name);

    // Set the menu-button animations
    imgButton = (ImageButton) findViewById(R.id.menu);
    imgButton.setImageResource(R.drawable.menu);
    rotForward = AnimationUtils.loadAnimation(this, R.anim.button_rotate);
    rotBack = AnimationUtils.loadAnimation(this, R.anim.button_rotate_back);

    // Set the Add Button
    add = (ImageButton) findViewById(R.id.add);
    add.setImageResource(R.drawable.add);

    add.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, CreateActivity.class);
            startActivity(intent);
          }
        });

    // Make the SlidingMenu
    menu = new SlidingMenu(this);
    menu.setMode(SlidingMenu.LEFT);
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    menu.setShadowDrawable(R.drawable.menu_shadow);
    menu.setShadowWidth(100);
    menu.setFadeDegree(0.35f);
    menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    menu.setMenu(R.layout.slidingmenu);
    menu.setSlidingEnabled(false);

    // Make the SlidingMenu show on click
    imgButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (!menu.isMenuShowing()) {
              imgButton.startAnimation(rotForward);
              add.setVisibility(View.GONE);
              imgButton.postDelayed(
                  new Runnable() {
                    @Override
                    public void run() {
                      imgButton.setImageResource(R.drawable.previous);
                    }
                  },
                  100);
            } else {
              imgButton.setImageResource(R.drawable.menu);
              imgButton.startAnimation(rotBack);
              add.setVisibility(View.VISIBLE);
            }
            menu.toggle();
          }
        });

    // Hide SlidingMenu
    Button events = (Button) findViewById(R.id.btnEvents);
    events.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            imgButton.setImageResource(R.drawable.menu);
            imgButton.startAnimation(rotBack);
            add.setVisibility(View.VISIBLE);
            menu.toggle();
          }
        });

    // Go to Settings
    Button settings = (Button) findViewById(R.id.btnSettings);
    settings.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
            startActivity(intent);
          }
        });
    getCountry();
  }
  private void prepareSearchViewAndActionBar() {
    // Postal address pickers (and legacy pickers) don't support search, so just show
    // "HomeAsUp" button and title.
    if (mRequest.getActionCode() == ContactsRequest.ACTION_PICK_POSTAL
        || mRequest.isLegacyCompatibilityMode()) {
      findViewById(R.id.search_view).setVisibility(View.GONE);
      final ActionBar actionBar = getSupportActionBar();
      if (actionBar != null) {
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
      }
      return;
    }

    // If ActionBar is available, show SearchView on it. If not, show SearchView inside the
    // Activity's layout.
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      final View searchViewOnLayout = findViewById(R.id.search_view);
      if (searchViewOnLayout != null) {
        searchViewOnLayout.setVisibility(View.GONE);
      }

      @SuppressLint("InflateParams")
      final View searchViewContainer =
          LayoutInflater.from(actionBar.getThemedContext())
              .inflate(R.layout.custom_action_bar, null);
      mSearchView = (SearchView) searchViewContainer.findViewById(R.id.search_view);

      // In order to make the SearchView look like "shown via search menu", we need to
      // manually setup its state.
      mSearchView.setIconifiedByDefault(true);
      mSearchView.setQueryHint(getString(R.string.hint_findContacts));
      mSearchView.setIconified(false);

      mSearchView.setOnQueryTextListener(this);
      mSearchView.setOnCloseListener(this);
      mSearchView.setOnQueryTextFocusChangeListener(this);

      actionBar.setCustomView(
          searchViewContainer,
          new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
      actionBar.setDisplayShowCustomEnabled(true);
      actionBar.setDisplayShowHomeEnabled(true);
      actionBar.setDisplayHomeAsUpEnabled(true);
    } else {
      mSearchView = (SearchView) findViewById(R.id.search_view);
      mSearchView.setQueryHint(getString(R.string.hint_findContacts));
      mSearchView.setOnQueryTextListener(this);

      // This is a hack to prevent the search view from grabbing focus
      // at this point.  If search view were visible, it would always grabs focus
      // because it is the first focusable widget in the window.
      mSearchView.setVisibility(View.INVISIBLE);
      mSearchView.postDelayed(
          new Runnable() {
            @Override
            public void run() {
              mSearchView.setVisibility(View.VISIBLE);
            }
          },
          FOCUS_DELAY);
    }

    // Clear focus and suppress keyboard show-up.
    mSearchView.clearFocus();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_home);
    mDrawerList = (ListView) findViewById(R.id.list_slidermenu);

    actionbar = getSupportActionBar();

    /*
     * actionbar.setDisplayHomeAsUpEnabled(true);
     * actionbar.setHomeButtonEnabled(true);
     */
    actionbar.setDisplayShowHomeEnabled(false);
    actionbar.setDisplayShowTitleEnabled(false);
    LayoutInflater mInflater = LayoutInflater.from(this);

    View mCustomView = mInflater.inflate(R.layout.actionbar_home, null);

    actionbar.setCustomView(mCustomView);
    actionbar.setDisplayShowCustomEnabled(true);
    // initDrawerLayout();
    // displayView(0);
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ActivityHome.this);
    languageType = sharedPreferences.getString("languageType", null);
    if (languageType.equals("1")) {
      myLocale = Locale.ENGLISH;
      Locale.setDefault(myLocale);
      android.content.res.Configuration config = new android.content.res.Configuration();
      config.locale = myLocale;
      getBaseContext()
          .getResources()
          .updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());

      // myLocale = new Locale(Locale.ENGLISH);
    } else if (languageType.equals("2")) {

      myLocale = new Locale("kn");
      Locale.setDefault(myLocale);
      android.content.res.Configuration config = new android.content.res.Configuration();
      config.locale = myLocale;
      getBaseContext()
          .getResources()
          .updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());

    } else if (languageType.equals("3")) {

      myLocale = new Locale("te");
      Locale.setDefault(myLocale);
      android.content.res.Configuration config = new android.content.res.Configuration();
      config.locale = myLocale;
      getBaseContext()
          .getResources()
          .updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
    }

    navDrawerItems = new ArrayList<NavDrawerItem>();
    navMenuIcons = getResources().obtainTypedArray(R.array.nav_drawer_icons);
    navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);

    navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1)));
    // Find People
    navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1)));
    // Photos
    navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1)));
    // Communities, Will add a counter here
    navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1)));
    // Pages
    navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));

    mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
    selectedMenu = 0;
    adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems, selectedMenu);
    mDrawerList.setAdapter(adapter);
  }