Java Code Examples for android.support.v7.widget.Toolbar#setNavigationOnClickListener()

The following examples show how to use android.support.v7.widget.Toolbar#setNavigationOnClickListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PaymentTypesActivity.java    From px-android with MIT License 6 votes vote down vote up
private void loadToolbarArrow(Toolbar toolbar) {
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }
    if (toolbar != null) {
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
 
Example 2
Source File: HelpFragment.java    From CapturePacket with MIT License 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    Toolbar toolbar =  view.findViewById(R.id.tool_bar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            FragmentActivity activity = getActivity();
            if (activity != null) {
                activity.getSupportFragmentManager()
                        .popBackStackImmediate();
            }
        }
    });
    TextView textView = view.findViewById(R.id.tv_content);
    textView.setAutoLinkMask(Linkify.WEB_URLS);
    textView.setLinkTextColor(0xffFF4081);
    textView.setLinksClickable(true);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 3
Source File: Update.java    From styT with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.a_ig);

    //Toolbar部分
    Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    mToolbar.setTitle("一个记事");
    mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
    mToolbar.setNavigationOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View p1) {
            finish();
        }
    });
    xft();
    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    viewPager = (ViewPager) findViewById(R.id.viewpager);
    setViewPager();

}
 
Example 4
Source File: SimpleActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.include_list_viewpager);
    // if (Build.VERSION.SDK_INT >= 21) {    //消除actionbar下的阴影线
    // getSupportActionBar().setElevation(0f);
    //   }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View p1) {
            finish();
        }
    });

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);

    //
    //nico.styTool.StatusBarUtil.setColorForDrawerLayout(this, mDrawerLayout, 0);
    //
}
 
Example 5
Source File: MainActivity.java    From Expense-Tracker-App with MIT License 5 votes vote down vote up
private void setUpToolbar() {
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mainDrawerLayout.openDrawer(GravityCompat.START);
        }
    });
}
 
Example 6
Source File: BaseActivity.java    From Android-skin-support with MIT License 5 votes vote down vote up
protected void initToolbar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle("Title");
    toolbar.setSubtitle("Subtitle");
    toolbar.setNavigationIcon(R.drawable.ic_settings_black_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(BaseActivity.this, SettingsActivity.class));
        }
    });
    toolbar.setOverflowIcon(getResources().getDrawable(R.drawable.ic_camera_24dp));
}
 
Example 7
Source File: WebViewActivity.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview_layout);

    mToolbar = (Toolbar) findViewById(R.id.webAuthToolbar);

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mToolbar.setNavigationOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mWebView.stopLoading();
            finish();
        }
    });


    mAccountBean = getIntent().getParcelableExtra(BundleArgsConstants.ACCOUNT_EXTRA);
    if (mAccountBean == null) {
        mAccountBean = BeeboApplication.getInstance().getAccountBean();
    }

    initView();
    initData();

}
 
Example 8
Source File: BaseCompatActivity.java    From YiZhi with Apache License 2.0 5 votes vote down vote up
protected void initTitleBar(Toolbar toolbar, String title) {
    toolbar.setTitle(title);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    toolbar.setNavigationIcon(R.mipmap.ic_arrow_back_white);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onBackPressedSupport();
        }
    });
}
 
Example 9
Source File: SpotInfoFragment.java    From android with MIT License 5 votes vote down vote up
private void setupLayout(View view) {
    if (isExpanded) {
        final Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
        if (toolbar != null) {
            toolbar.setNavigationIcon(R.drawable.ic_navigation_arrow_back);
            TypefaceHelper.setTitle(getActivity(), toolbar, mTitle);
            toolbar.setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    getActivity().onBackPressed();
                }
            });
            toolbar.inflateMenu(R.menu.menu_spot_info);
            toolbar.setOnMenuItemClickListener(this);
        }

        // Setup the recycler view
        final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        vRecyclerView.setLayoutManager(layoutManager);
    } else {
        view.setOnClickListener(this);

        vTitle.setText(mTitle);

        vCheckinBtn.setOnClickListener(this);
    }
}
 
Example 10
Source File: GSIDWebViewActivity.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview_layout);

    Toolbar mToolbar = (Toolbar) findViewById(R.id.webAuthToolbar);

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mToolbar.setNavigationOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mWebView.stopLoading();
            finish();
        }
    });


    mAccountBean = getIntent().getParcelableExtra(BundleArgsConstants.ACCOUNT_EXTRA);
    if (mAccountBean == null) {
        mAccountBean = BeeboApplication.getInstance().getAccountBean();
    }

    initView();
    initData();

}
 
Example 11
Source File: SettingsActivity.java    From Leisure with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Language
    mLang = Utils.getCurrentLanguage();
    if (mLang > -1) {
        Utils.changeLanguage(this, mLang);
    }


    //set Theme
    if(Settings.isNightMode){
        this.setTheme(R.style.NightTheme);
    }else{
        this.setTheme(R.style.DayTheme);
    }
    Settings.swipeID = Settings.getInstance().getInt(Settings.SWIPE_BACK,0);

    setContentView(R.layout.activity_settings);

    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(R.string.setting);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    getFragmentManager().beginTransaction().replace(R.id.framelayout,new SettingsFragment()).commit();
}
 
Example 12
Source File: JSWebViewActivity.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview_layout);

    mToolbar = (Toolbar) findViewById(R.id.webAuthToolbar);

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mToolbar.setNavigationOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mWebView.stopLoading();
            finish();
        }
    });


    mAccountBean = getIntent().getParcelableExtra(BundleArgsConstants.ACCOUNT_EXTRA);
    if (mAccountBean == null) {
        mAccountBean = BeeboApplication.getInstance().getAccountBean();
    }

    initView();
    initData();

}
 
Example 13
Source File: AboutActivity.java    From Leisure with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Language
    mLang = Utils.getCurrentLanguage();
    if (mLang > -1) {
        Utils.changeLanguage(this, mLang);
    }

    //set Theme
    if(Settings.isNightMode){
        this.setTheme(R.style.NightTheme);
    }else{
        this.setTheme(R.style.DayTheme);
    }

    setContentView(R.layout.activity_about);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(getString(R.string.about));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });

    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);


    getFragmentManager().beginTransaction().replace(R.id.framelayout,new AboutFragment()).commit();
}
 
Example 14
Source File: GroupProfileActivity.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
private void initToolbar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("群组信息");
    setSupportActionBar(toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });
}
 
Example 15
Source File: AuthActivity.java    From Varis-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes toolbar
 */
private void initToolbar() {
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();

    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
        toolbar.setNavigationOnClickListener(v -> onBackPressed());
    }
}
 
Example 16
Source File: InvitationCategoryActivity.java    From PlayTogether with Apache License 2.0 5 votes vote down vote up
@Override
public void afterCreate()
{
	mCategory = getIntent().getStringExtra(EXTRA_CATEGORY);
	ActionBar actionBar = getSupportActionBar();
	if (actionBar != null)
	{
		actionBar.setDisplayHomeAsUpEnabled(true);
	}
	Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
	toolbar.setNavigationOnClickListener(new View.OnClickListener()
	{
		@Override
		public void onClick(View v)
		{
			finish();
		}
	});
	setHeader();
	EventBus.getDefault().register(this);
	//初始化SwipeRefreshLayout
	mSwipeRefreshLayout.setColorSchemeResources(R.color.primary_color);
	initEvent();
	//初始化recyclerview
	mRvInvitation.setLayoutManager(mLayoutManager = new LinearLayoutManager(this,
					LinearLayoutManager.VERTICAL, false));
	//加载数据并显示加载框
	InvitationCondition condition = new InvitationCondition();
	condition.setCategory(mCategory);
	mCondition = condition;
	showProgress();
	mController.loadData(condition);
}
 
Example 17
Source File: BaseCompatActivity.java    From meiShi with Apache License 2.0 5 votes vote down vote up
/**
 * toolbar点击返回,模拟系统返回
 * 设置toolbar 为箭头按钮
 * app:navigationIcon="?attr/homeAsUpIndicator"
 *
 * @param toolbar
 */
public void toobarAsBackButton(Toolbar toolbar) {
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
}
 
Example 18
Source File: AboutFragment.java    From ESeal with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_about, container, false);

    aboutContent = view.findViewById(R.id.about_content);

    webContent = view.findViewById(R.id.web_content);
    webView = (WebView) view.findViewById(R.id.webView);
    progressBar = (ContentLoadingProgressBar) view.findViewById(R.id.progress);
    webErrorContent = view.findViewById(R.id.web_error_content);

    appVersionName = (AppCompatTextView) view.findViewById(R.id.app_version_name);
    appNewVersionHint = (AppCompatTextView) view.findViewById(R.id.app_new_version_hint);
    appNewVersionName = (AppCompatTextView) view.findViewById(R.id.app_new_version_name);

    String versionName = VersionHelper.getVersionName(getContext());
    appVersionName.setText(versionName);

    view.findViewById(R.id.update_version_area).setOnClickListener(__ -> mPresenter.checkUpdateVersion(false));

    view.findViewById(R.id.app_introduction).setOnClickListener(__ -> showIntroduction());

    view.findViewById(R.id.app_thanks).setOnClickListener(__ -> showThanks());

    view.findViewById(R.id.app_about_me).setOnClickListener(__ -> showAboutMe());

    toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(__ -> {
        if (webContent.getVisibility() == View.VISIBLE) {
            webContent.setVisibility(View.GONE);
            aboutContent.setVisibility(View.VISIBLE);
            toolbar.setTitle(R.string.about);
        } else if (webContent.getVisibility() == View.GONE) {
            getActivity().onBackPressed();
        }
    });

    setupWebView();

    return view;
}
 
Example 19
Source File: Main4Activity.java    From styT with Apache License 2.0 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_4main);
        final SharedPreferences i = getSharedPreferences("pHello500", 0);
        Boolean o0 = i.getBoolean("FIRST", true);
        if (o0) {//第一次截图
            /*
            AppCompatDialog alertDialog = new AlertDialog.Builder(this)
                    .setTitle("其他规则")
                    .setMessage("邀请一个人可以得*+0.10现金{0.25现金上限25人<其他现金无上限}\n推荐 一个人截一图")
                    .setNeutralButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            i.edit().putBoolean("FIRST", false).apply();

                        }
                    }).setCancelable(false).create();
            alertDialog.show();*/
        } else {

        }

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        toolbar.setSubtitleTextAppearance(this, R.style.ts);
        toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
//		设置导航图标
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View p1) {
                finish();
            }
        });
        // finish();
        xft();
        Intent intent = new Intent(this, DownloadService.class);
        startService(intent);
        bindService(intent, mServiceConnection, BIND_AUTO_CREATE);
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
        }

        myUser = BmobUser.getCurrentUser(MyUser.class);
        init();
        listView = (android.support.v7.widget.ListViewCompat) findViewById(R.id.lv_feedback);

        emptyView = new TextView(this);
        emptyView.setText("");
        emptyView.setGravity(Gravity.CENTER);
        //emptyView.setTextSize(15); //设置字体大小
        LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        addContentView(emptyView, params);
        listView.setEmptyView(emptyView);

        BmobQuery<xp> query = new BmobQuery<>();
        query.order("-createdAt");
        query.findObjects(new FindListener<xp>() {

            @Override
            public void done(List<xp> object, BmobException e) {
                if (e == null) {
                    adapter = new FeedbackAdapter(Main4Activity.this, object);
                    listView.setAdapter(adapter);
                } else {
                    emptyView.setText((CharSequence) object);
                }
            }

        });

    }
 
Example 20
Source File: ChatActivity.java    From MaterialQQLite with Apache License 2.0 4 votes vote down vote up
@SuppressLint("NewApi")
    private void initView() {
    //    m_txtName = (TextView)findViewById(R.id.chat_txtName);
        m_lvMsg = (ListView)findViewById(R.id.chat_lvMsg);
        swipeRefreshLayout_chat= (PullRefreshLayout) findViewById(R.id.swipeRefreshLayout_chat);
        m_btnFace = (ImageButton)findViewById(R.id.chat_btnFace);
    //    m_btnMore = (ImageButton)findViewById(R.id.chat_btnMore);
        m_edtMsg = (EditText) findViewById(R.id.chat_edtMsg);
        m_btnSend = (Button) findViewById(R.id.chat_btnSend);
        m_faceBar = findViewById(R.id.chat_facebar);
        m_vpFace = (ViewPager)findViewById(R.id.chat_vpFace);
        m_dotBar = (LinearLayout) findViewById(R.id.chat_dotbar);



        m_btnFace.setOnClickListener(this);
        m_edtMsg.setOnClickListener(this);
        m_btnSend.setOnClickListener(this);

        if (m_nType != IS_GROUP)
          //  m_txtName.setText(m_strBuddyName);
            m_txtName=m_strBuddyName;
        else
         //   m_txtName.setText(m_strGroupName);
        m_txtName=m_strGroupName;

        initChatMsgListView();	// 初始化聊天消息列表框
        initFaceBar();			// 初始化表情栏

        m_nCurFacePage = 0;
        m_vpFace.setCurrentItem(1);

        toolbar = (Toolbar) findViewById(R.id.toolbar_chat);
        toolbar.setNavigationIcon(R.drawable.qqicon);
        toolbar.setTitle(m_txtName);

        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        chat_inputbar= (LinearLayout) findViewById(R.id.chat_inputbar);

        toolbar.setBackgroundColor(color_theme);
        chat_inputbar.setBackgroundColor(color_theme);

        // 去除 ListView 上下边界蓝色或黄色阴影
//		ListView actualListView = m_lvMsg.getRefreshableView();
//		if (Integer.parseInt(Build.VERSION.SDK) >= 9) {
//			actualListView.setOverScrollMode(View.OVER_SCROLL_NEVER);
//        }
    }