当前位置:网站首页>CommonTitleBar hide left right
CommonTitleBar hide left right
2022-07-27 07:55:00 【Kamchatka Bear Man】
CommonTitleBar Is a good custom top bar control , Meet a need , Same page , According to the fields returned by the server , Determine whether a button in the top bar is displayed or hidden ,true and false.
For this need , Write a simple demo, To achieve this effect
step1:
package com.uxdpen.ui.android.activity.examples;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import com.uxdpen.ui.android.R;
import com.wuhenzhizao.titlebar.widget.CommonTitleBar;
public class TitlebarActivity extends AppCompatActivity {
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_left_text);
final CommonTitleBar titleBar = (CommonTitleBar) findViewById(R.id.titlebar);
titleBar.getLeft();
TextView mTextView = titleBar.getLeftTextView();
TextView mTextView2 = titleBar.getRightTextView();
View view = titleBar.getLeftCustomView();//.setVisibility(View.INVISIBLE);
mTextView.setVisibility(View.INVISIBLE);
mTextView2.setVisibility(View.VISIBLE);
System.out.println(mTextView);
titleBar.setListener(new CommonTitleBar.OnTitleBarListener() {
@Override
public void onClicked(View v, int action, String extra) {
if (action == CommonTitleBar.ACTION_LEFT_BUTTON || action == CommonTitleBar.ACTION_LEFT_TEXT) {
Log.e("TAG", " test ");
} else if (action == CommonTitleBar.ACTION_RIGHT_BUTTON || action == CommonTitleBar.ACTION_RIGHT_TEXT) {
Log.e("TAG", " details ");
}
}
});
titleBar.setDoubleClickListener(new CommonTitleBar.OnTitleBarDoubleClickListener() {
@Override
public void onClicked(View v) {
Log.e("TAG", " Wind speed reaches yes ");
}
});
}
}
step2:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:titlebar="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_red_light"
android:fitsSystemWindows="false"
android:orientation="vertical"
tools:context="com.uxdpen.ui.android.activity.examples.TitlebarActivity">
<com.wuhenzhizao.titlebar.widget.CommonTitleBar
android:id="@+id/titlebar"
android:layout_width="match_parent"
android:layout_height="60dp"
titlebar:centerText=" The title bar "
titlebar:centerType="textView"
titlebar:fillStatusBar="true"
titlebar:leftDrawable="@drawable/comm_titlebar_back_normal"
titlebar:leftDrawablePadding="0dp"
titlebar:leftText=" return "
titlebar:rightText=" details "
titlebar:leftType="textView"
titlebar:rightType="textView" />
</LinearLayout>
step3:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.wuhenzhizao:titlebar:1.0.6'
}
end
边栏推荐
- DASCTF2022.07赋能赛密码wp
- Harbor can't log in with the correct password
- 正则 和 sed 练习
- [flight control development foundation tutorial 4] crazy shell · open source formation UAV - serial port (optical flow data acquisition)
- C# 事件用法案例 订阅事件+=
- 将对象转换为键值对
- 【飞控开发基础教程4】疯壳·开源编队无人机-串口(光流数据获取)
- 杂谈:手里有竿儿,肩上有网,至于背篓里有多少鱼真的重要吗?
- Things come to conform, the future is not welcome, at that time is not miscellaneous, neither love
- How does slf4j configure logback?
猜你喜欢

Demo submit a program and obtain ALV data of the program

将对象转换为键值对

How to obtain the cash flow data of advertising services to help analyze the advertising effect?

企业架构驱动的数字化转型!

2020国际机器翻译大赛:火山翻译力夺五项冠军

Combined use of C WinForm form form event and delegate

LeetCode56. 合并区间

剑指 Offer 58 - I. 翻转单词顺序

Convert objects to key value pairs

什么是真正的HTAP?(一)背景篇
随机推荐
API version control [eolink translation]
企业架构驱动的数字化转型!
JS存取cookie示例
综合案例、
Gossip: is rotting meat in the pot to protect students' rights and interests?
Comprehensive cases
【QT】capture. Obj:-1: error: lnk2019: unresolved external symbols__ imp_ Htons (solution)
Lua有状态迭代器
Stored procedures and functions
shell脚本学习day01
Digital transformation driven by enterprise architecture!
RPC remote procedure call
[day42 literature intensive reading] a Bayesian model of perfect head centered velocity during smooth pursuit eye movement
瑞芯微RK3399-I2C4挂载EEPROM的修改案例
Hu related configuration
Can Linux install sqlserver
Primary key in MySQL secondary index - MySQL has a large number of same data paging query optimization
Practical new drug R & D project management platform
【小程序】如何获取微信小程序代码上传密钥?
C# 事件用法案例 订阅事件+=