当前位置:网站首页>CommonTitleBar hide left right
CommonTitleBar hide left right
2022-07-27 07:49:00 【勘察加熊人】
CommonTitleBar 是一个很好的自定义的顶部栏控件,碰到一个需求,同一个页面,根据服务器返回的字段,判断顶部栏某一个按钮的显示和隐藏,true和false。
为了这个需求,简单写一个demo,实现这个效果
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", "测试");
} else if (action == CommonTitleBar.ACTION_RIGHT_BUTTON || action == CommonTitleBar.ACTION_RIGHT_TEXT) {
Log.e("TAG", "详情");
}
}
});
titleBar.setDoubleClickListener(new CommonTitleBar.OnTitleBarDoubleClickListener() {
@Override
public void onClicked(View v) {
Log.e("TAG", "风速达到是");
}
});
}
}
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="标题栏"
titlebar:centerType="textView"
titlebar:fillStatusBar="true"
titlebar:leftDrawable="@drawable/comm_titlebar_back_normal"
titlebar:leftDrawablePadding="0dp"
titlebar:leftText="返回"
titlebar:rightText="详情"
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
边栏推荐
- 【pytorch】ResNet18、ResNet20、ResNet34、ResNet50网络结构与实现
- Solidity智能合约开发 — 3.3-solidity语法控制结构
- 【Golang】golang开发微信公众号网页授权功能
- 二零二零年终总结
- The integrated real-time HTAP database stonedb, how to replace MySQL and achieve nearly 100 times the improvement of analysis performance
- Use Amazon dynamodb and Amazon S3 combined with gzip compression to maximize the storage of player data
- Cadence (XI) silk screen printing adjustment and subsequent matters
- RPC remote procedure call
- Regular expression foundation sorting
- 容器内使用sudo报错bash: sudo: command not found解决
猜你喜欢

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

存储过程与函数

如何在电脑端登陆多个微信

【StoneDB Class】入门第一课:数据库知识科普

LeetCode56. 合并区间

综合案例、
![[resolved] SSO forwarding succeeded, and there was an unexpected error (type=internal server error, status=500) caused by parameters in the forwarding URL](/img/05/41f48160fa7895bc9e4f314ec570c5.png)
[resolved] SSO forwarding succeeded, and there was an unexpected error (type=internal server error, status=500) caused by parameters in the forwarding URL

【已解决】单点登录成功SSO转发,转发URL中带参数导致报错There was an unexpected error (type=Internal Server Error, status=500)

RPC remote procedure call

【Day42 文献精读】A Bayesian Model of Perceived Head-Centered Velocity during Smooth Pursuit Eye Movement
随机推荐
opengl-shader学习笔记:varying变量
glGetUniformLocation,glUniform4f
Framework of electronic mass production project -- basic idea
电子量产项目框架--基本思想
Cadence (XI) silk screen printing adjustment and subsequent matters
shell awk相关练习
【已解决】新版Pycharm(2022)连接服务器进行上传文件报错“Command rsync is not found in PATH”,无法同步文件
一体化实时HTAP数据库StoneDB,如何替换MySQL并实现近百倍分析性能的提升
Shell functions and arrays exercises
C language: random number + Hill sort
Temperature and humidity measurement and display device based on Arduino
HU相关配置
What other methods are available for MySQL index analysis besides explain
【Golang】golang开发微信公众号网页授权功能
【Day42 文献精读】A Bayesian Model of Perceived Head-Centered Velocity during Smooth Pursuit Eye Movement
杂谈:把肉都烂在锅里就是保障学生权益了?
瑞芯微RK3399-I2C4挂载EEPROM的修改案例
kalibr标定realsenseD435i --多相机标定
yhb_ sysbench
glGetUniformLocation,glUniform4f