tabhost

Android TabHost

﹥>﹥吖頭↗ 提交于 2020-01-09 17:24:10
学习自 鲁迅认识的那个猹 Overview TabHost早就已经被Google弃用了。但是它弃归它弃我用归我用。但是Google也推出了替代品。 FragmentTabHost TabLayout(Material Design) 如何优雅的使用TabHost 按照国际惯例,我们先看一下代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TabHost android:id="@+id/navTH" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:layout_width="match_parent" android:layout_height="match

仿安智市场UI框架布局之fragment+tabhost底部菜单

给你一囗甜甜゛ 提交于 2019-12-30 17:23:08
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 第一部分就是你们现在看的这个贴,主要功能:实现fragment_+tabhost来搭建整个app的大体UI框架,底部是一个可切换的选项卡(安智市场中的底部选项卡的切换动画效果略过,没写,太困了,码完字去睡觉)。 第二部分:也就是这个即将写的下一个帖子,因为今天实在太晚了,明天还要上班(Zzzzz...),主要功能:使用viewpagerindicator控件,实现左右滑动加载分页数据,还有android 4.2更新的新特性:Fragment in fragment(嵌套)。 这部分很快会更新。真的。 <br>现在来看看安智市场的app效果 <br>然后来看看现在这个帖子要实现的功能的demo效果 不会很难看吧,见笑了!呵呵!!!动画效果没做。木有时间。 <br>现在来说说代码,其实我之前在eoe写过一个类似的,不过现在理解更深刻,有改进一部分。 首先必须是布局文件啦,主要的布局文件是:activity_main.xml <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id=" @android :id/tabhost" android:layout_width="match_parent" android

Tabhost中子Activity使用startActivityForResult后获取不到回调值问

余生长醉 提交于 2019-12-10 07:52:30
最近一段时间没有更新博客了,是因为一直忙于一个Android的项目,给某企业做一款基于北斗定位的物流车载终端。这个项目的难点在于平板的通信方式不是采用传统使用自带的通信模块,而是使用串口通过车载部标仪来进行通讯。对此,需要使用到NDK来开发和串口的通信服务,这个项目中我主要负责Android平板的所有界面和交互制作、以及业务逻辑的实现。我的另一名同学负责串口通信的开发,二人合作开发这个项目。整个项目组有十几个人,Android端就我们两个,所以任务还是很重的,目前进度过半,还是天天加班,虽然很累,但是成长的路上少不了辛苦,遇到问题、解决问题,我们一直在路上。 回归正题,今天主要是记录一个我开开发中遇到的一个小问题,其实这不是第一次遇到,之所以记录下来是为了提供我的解决办法供大家参考! 问题描述:当主Activity A是一个Tabhost布局,或者是一个ActivityGroup,在子Activity B中使用startActivityForResult来开启一个新的Activity C,新Activity C操作完后返回Activity B并传回一个值,这个值在Activity B的onActivityResult方法中无法取到。 问题原因:startActivityForResult后触发的回调方法并不在Activity B中,而是在Activity A中

android自定义tabhost,tabcontent用intent获得

≡放荡痞女 提交于 2019-12-05 14:58:27
自己改的自定义tabhost组建,效果图如左。有更好的朋友可以相互交流一下,嘿嘿。 1.先上AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=" http://schemas.android.com/apk/res/android " package="com.priscilla" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="7" /> <application android:icon="@drawable/icon" android:label="@string/app_name" > <activity android:label="@string/app_name" android:name=".MyTab" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>

Tabhost tutorial broken? [duplicate]

匿名 (未验证) 提交于 2019-12-03 08:52:47
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Possible Duplicate: Anyone know what this error mean for android tabs? I have been trying to do the TabHost tutorial in the SDK but for some reason, is appears to break. On Step 4 I copy and paste the xml code, I get an error that prevents it from inflating properly. the error is: Error in an XML file : aborting build . This is in the graphical layout of the xml file. Error during post inflation process : TabHost requires a TabWidget with id "android:id/tabs" , View found with id "tabs" is 'com.android.layoutlib.bridge.MockView'

Badge on Android TabHost

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to implement the functionality same as was there in iPhone I implemented the custom Tabhost same as in iPhone in the bottom bar. I can set two Icons for Normal/Selected state but I need the dynamic icon with number of notifications as given in Image. Thanks 回答1: Android ViewBadger may be the solution for you. (FYI, i haven't implemented it yet) Here is the snap you can have as an output by this solution: 回答2: This is an example of How to add a badge in tab chat_tab.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res

Why the tab widget is above the content in android?

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Currently I work on a tabhost layout. In most android app the layout is: tab1 | tab 2 ____________ Tab 1 content (if I press on tab1) However, what I would like to achieve is Tab 1 content (if I press on tab1) ____________ tab1 | tab 2 Here is the main xml (backbone of app) : <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <FrameLayout android:id="@android:id/tabcontent" android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="0" /> <FrameLayout

java.lang.IllegalStateException… at tabhost.add(tabspec);

匿名 (未验证) 提交于 2019-12-03 01:45:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hi guyzz I have TabActivity as following simple code public class TabhostActivity extends Activity{ TabHost host; public class TabhostActivity extends Activity{ TabHost host; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.tablayout); host = (TabHost) findViewById(R.id.mytabhost); host.setup(); Intent intent = new Intent(getApplicationContext(), RatingBarActivity.class); TabHost.TabSpec spec = host.newTabSpec("positions")

TabHost中的Activity调用overridePendingTransition()方法无效

心不动则不痛 提交于 2019-12-03 01:37:59
在定义的MyActivity中,继承的是 TabActivity ,添加了几个Activity,比如说A、B、C,采用了TabHost管理切换不同的主页面。 现在A如果展示的是一个列表,点击每一项,可以进入A的子页面,这时候希望具有自定义的动画效果,但是发现仅仅使用 overridePendingTransition() 却没有效果。 网上查阅了些资料,发现这个可以用,于是对其稍微整理了下,没有深入分析,贴出来仅作参考。 原文链接: http://blog.sina.com.cn/u/2377683267 首先,要说的是ActivityA到ActivityB的切换这个相对简单,只要overridePendingTransitio n(In,out)。这里不就说了。但是这里要说名的ActivityA不能TABHost里面的一个。因为Tabhost里面有自己的Activity其实还没有跳出Tabhost生命。这个可以Log,Tabhost生命周期试试就知道了。其实Tabhost里面嵌套的Activity都在生命周期都在Tabhost里面。这样的话,Tabhost里面的Activity跳转到其他(非Tabhost里面的Activity)时,调用overridePendingTransitio n(In,out)。其跳转效果还是默认的,这么句代码的效果是不会出现的。

How to hide a tab in Android tab layout?

匿名 (未验证) 提交于 2019-12-03 01:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a tab layout containing 3 tabs. I want to add 4th tab at run time and hide this tab after some time. Please let me know how to hide a tab in Android. 回答1: Get TabHost from resource as TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); Then runtime use this tabHost.getTabWidget().getChildAt(3).setVisibility(View.GONE); Supposing that you are trying to hide 4th Tab.( So 3 is used ) 文章来源: How to hide a tab in Android tab layout?