示例#1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(
        Window.FEATURE_INDETERMINATE_PROGRESS); // for progress it will be passed before layout

    // navigation
    if (savedInstanceState != null) {
      mActiveViewId = savedInstanceState.getInt(STATE_ACTIVE_VIEW_ID);
    }

    mMenuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_WINDOW);
    mMenuDrawer.setMenuView(R.layout.menu_scrollview); // this is the layout for

    ////////////////////////////////////////////////////
    // Action bar
    ActionBar mActionBar;
    LayoutInflater mInflater;
    View mCustomView;
    TextView mTitleTextView;
    mActionBar = getSupportActionBar();
    mActionBar.setDisplayShowHomeEnabled(false);
    mActionBar.setDisplayShowTitleEnabled(false);
    mInflater = LayoutInflater.from(this);
    mCustomView = mInflater.inflate(R.layout.menu, null);
    mTitleTextView = (TextView) mCustomView.findViewById(R.id.title_text);
    mTitleTextView.setText("Live");
    mTitleTextView.setTextSize(20);

    mActionBar.setCustomView(mCustomView);
    mActionBar.setDisplayShowCustomEnabled(true);
    // mActionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.at_header_bg));
    ImageButton ibItem1 = (ImageButton) findViewById(R.id.btn_slide);
    ibItem1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            mMenuDrawer.toggleMenu();
          }
        });

    /////////////////////////////////////////////

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      //           getActionBar().setDisplayHomeAsUpEnabled(true);
      // this is for the color of title bar
      ColorDrawable colorDrawable = new ColorDrawable();
      int myColor = this.getResources().getColor(R.color.menu4);
      colorDrawable.setColor(myColor);
      android.app.ActionBar actionBar = getActionBar();
      actionBar.setBackgroundDrawable(colorDrawable);
    }

    // mContentTextView = (TextView) findViewById(R.id.contentText);
    findViewById(R.id.item1).setOnClickListener(this);
    findViewById(R.id.item2).setOnClickListener(this);
    findViewById(R.id.item3).setOnClickListener(this);
    findViewById(R.id.item4).setOnClickListener(this);
    findViewById(R.id.item5).setOnClickListener(this);
    findViewById(R.id.item6).setOnClickListener(this);
    findViewById(R.id.item7).setOnClickListener(this);
    findViewById(R.id.item8).setOnClickListener(this);

    TextView activeView = (TextView) findViewById(mActiveViewId);
    if (activeView != null) {
      mMenuDrawer.setActiveView(activeView);
      // mContentTextView.setText("Active item: " + activeView.getText());
    }

    Display display = getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    mMenuDrawer.setMenuSize(width / 4); // size of menu
    mMenuDrawer.setDropShadow(android.R.color.transparent); // removin showdo
    // navigation

    if (isNetworkOnline() == true) { // starting settings if internet is not working
      internt_count = true;
      iamcallin(); // calling the function to build everything

    } else if (isNetworkOnline() == false) {
      setContentView(R.layout.nointernet); // giving new layout to drawer
      // setContentView(R.layout.nointernet);
      internt_count = false;
      Button button = (Button) findViewById(R.id.nointernet_refresh);

      button.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View arg0) {

              Intent myIntent = new Intent(live_first.this, live_first.class); // refreshing

              startActivity(myIntent);
              finish();
            }
          });
    }
  }