当前位置: 首页 > news >正文

python的网站开发源码群晖 nas做网站 推荐

python的网站开发源码,群晖 nas做网站 推荐,公司运营是做什么的,想自己做网站该学些什么本文实例为大家分享了Android实现底部切换标签的具体代码#xff0c;供大家参考#xff0c;具体内容如下实现底部通用切换标签 #xff0c;嵌套Fragment#xff0c;方便自定义布局自定义控件#xff1a;widget_tab_view.xmlandroid:layout_widthmatch_parenta…本文实例为大家分享了Android实现底部切换标签的具体代码供大家参考具体内容如下实现底部通用切换标签 嵌套Fragment方便自定义布局自定义控件widget_tab_view.xmlandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:idid/tab_imageandroid:layout_width20dpandroid:layout_height20dp /android:idid/tab_labelandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textColor#666666android:textSize12sp /定义单个标签public class TabView extends LinearLayout {private ImageView mTabImage;private TextView mTabLable;public TabView(Context context) {super(context);initView(context);}public TabView(Context context, Nullable AttributeSet attrs) {super(context, attrs);initView(context);}public TabView(Context context, Nullable AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);initView(context);}private void initView(Context context) {setOrientation(VERTICAL);setGravity(Gravity.CENTER);LayoutInflater.from(context).inflate(R.layout.widget_tab_view, this, true);mTabImage (ImageView) findViewById(R.id.tab_image);mTabLable (TextView) findViewById(R.id.tab_label);}public void initData(TabItem tabItem) {mTabImage.setImageResource(tabItem.imageResId);mTabLable.setText(tabItem.lableResId);}}定义单个标签的entitypublic class TabItem {public int imageResId;public int lableResId;public Class extends Fragment tagFragmentClz;public TabItem(int imageResId, int lableResId) {this.imageResId imageResId;this.lableResId lableResId;}public TabItem(int imageResId, int lableResId, Class extends Fragment tagFragmentClz) {this.imageResId imageResId;this.lableResId lableResId;this.tagFragmentClz tagFragmentClz;}}定义底部切换标签控件public class BottomTabLayout extends LinearLayout implements View.OnClickListener {private ArrayList tabs;private OnTabClickListener listener;private int tabCount;private View selectedView;public BottomTabLayout(Context context) {super(context);initView();}public BottomTabLayout(Context context, Nullable AttributeSet attrs) {super(context, attrs);initView();}public BottomTabLayout(Context context, Nullable AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);initView();}private void initView() {setOrientation(HORIZONTAL);}public void setCurrentTab(int i) {if (i tabCount i 0) {View view getChildAt(i);onClick(view);}}public void initData(ArrayList tabs, OnTabClickListener listener) {this.tabs tabs;this.listener listener;LayoutParams params new LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT);params.weight 1;params.gravity Gravity.CENTER;if (tabs ! null tabs.size() 0) {tabCount tabs.size();TabView mTabView null;for (int i 0, len tabs.size(); i len; i) {mTabView new TabView(getContext());mTabView.setTag(tabs.get(i));mTabView.initData(tabs.get(i));mTabView.setOnClickListener(this);addView(mTabView, params);}} else {throw new IllegalArgumentException(tabs can not be empty);}}Overridepublic void onClick(View view) {if (selectedView ! view) {listener.onTabClick((TabItem) view.getTag());view.setSelected(true);if (selectedView ! null) {selectedView.setSelected(false);}selectedView view;}}public interface OnTabClickListener {void onTabClick(TabItem tabItem);}}Activitypublic class MainActivity extends AppCompatActivity implements BottomTabLayout.OnTabClickListener {private BottomTabLayout tab_layout;private ArrayList tabs;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);setTitle(底部切换标签);tab_layout (BottomTabLayout) findViewById(R.id.tab_layout);initBottomTab();tab_layout.setCurrentTab(0);}private void initBottomTab() {tabs new ArrayList();tabs.add(new TabItem(R.drawable.selector_tab_msg, R.string.wechat, OneFragment.class));tabs.add(new TabItem(R.drawable.selector_tab_contact, R.string.contacts, TwoFragment.class));tabs.add(new TabItem(R.drawable.selector_tab_moments, R.string.discover, ThreeFragment.class));tabs.add(new TabItem(R.drawable.selector_tab_profile, R.string.me, FourFragment.class));tab_layout.initData(tabs, this);}private Fragment lastFragment;Overridepublic void onTabClick(TabItem tabItem) {try {Fragment tmpFragment getSupportFragmentManager().findFragmentByTag(tabItem.tagFragmentClz.getSimpleName());FragmentTransaction transaction getSupportFragmentManager().beginTransaction();if (tmpFragment null) {tmpFragment tabItem.tagFragmentClz.newInstance();transaction.add(R.id.fl_container, tmpFragment, tabItem.tagFragmentClz.getSimpleName());if (lastFragment ! null) {transaction.hide(lastFragment);}transaction.commitAllowingStateLoss();} else {transaction.show(tmpFragment);if (lastFragment ! null) {transaction.hide(lastFragment);}transaction.commitAllowingStateLoss();}lastFragment tmpFragment;} catch (Exception e) {e.printStackTrace();}}}布局文件xmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticaltools:contextcom.sample.bottomtab.MainActivityandroid:idid/fl_containerandroid:layout_widthmatch_parentandroid:layout_height0dpandroid:layout_weight1android:background#ffffff /android:layout_widthmatch_parentandroid:layout_height1dpandroid:background#dcdcdc /android:idid/tab_layoutandroid:layout_widthmatch_parentandroid:layout_height48dpandroid:background#ffffff /以上就是本文的全部内容希望对大家的学习有所帮助也希望大家多多支持脚本之家。
http://www.zqtcl.cn/news/385714/

相关文章:

  • 网站开发 模板 c沈阳市建设工程质量检测中心网站
  • 企业网站设计专业好吗做钓鱼网站要具备什么
  • 广西备案工信部网站用asp.net做后台网站
  • 静态网站漏洞wordpress 外卖
  • 暗网做网站温州做网络推广的公司
  • 网站描述 修改上海火迎网络推广运营优化
  • 黄石网站建设哪家专业做个网站费用
  • 免费做的网站怎么设置域名解析宁夏百度seo
  • 化妆品产品的自建网站有哪些阿里云cdn wordpress错位
  • 增加网站流量网站新闻字体
  • 做外贸建网站需要推广吗服装如何做微商城网站
  • 上海市建设安全协会网站查询考试伪静态 wordpress
  • 网站免费建站o网站编程多少钱
  • 建设网站开发海外推广服务
  • 网站建设需要提供的资料文档营销平台建设
  • 做个响应式网站多少钱河南网络推广系统
  • wordpress的后台文章图文发布清远市seo广告优化
  • 长沙的互联网网站公司招标文件免费下载网站
  • icp备案系统网站品网站建设公司排名
  • 什么网站可以做音乐相册可信的品牌网站建设
  • 洛阳网站建设优惠公司网站查询ip地址
  • 学校网站模版电影网站要怎样做才有出路
  • 无锡网站建设 微信企业网站建设与管理期末考试
  • 海南海口网站开发公司怎么建立微网站?
  • 网站建设 鄂icp备app 微网站
  • 西安做网站seo网站站内优化怎么做
  • 建设网站方案公司wordpress 视差主题
  • 网站 建设 语言wordpress同步
  • 三水 网站建设建设部网站网上大厅
  • 深圳高端企业官方网站建设最好的网站设计开发公司