1.xml布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ptas_operation_bottom_bar" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:gravity="center_vertical" android:orientation="horizontal" android:paddingLeft="0.6600001dip" android:paddingRight="0.6600001dip">
<RadioGroup android:id="@+id/main_radio" style="@style/Ptas_Tab_Radio_Group_Bg" android:layout_gravity="bottom">
<RadioButton android:id="@+id/radio_navigation" style="@style/Ptas_Tab_Bottom" android:layout_marginTop="2.0dip" android:text="文字一" />
<RadioButton android:id="@+id/radio_vary" style="@style/Ptas_Tab_Bottom" android:layout_marginTop="2.0dip" android:text="文字一" />
<RadioButton android:id="@+id/radio_doing" style="@style/Ptas_Tab_Bottom" android:layout_marginTop="2.0dip" android:text="文字一" />
<RelativeLayout android:id="@+id/notice_re" style="@style/Ptas_Tab_Bottom_Notice">
<RadioButton android:id="@+id/radio_notice" style="@style/Ptas_Tab_Bottom" android:layout_centerInParent="true" android:layout_marginTop="2.0dip" android:text="文字一" />
<TextView android:id="@+id/notice_count_text" android:layout_width="28dip" android:layout_height="28dip" android:layout_alignParentRight="true" android:layout_alignParentTop="true"
android:background="@drawable/notice_count" android:gravity="center" android:text="0" android:textSize="13dip" android:textStyle="bold" />
</RelativeLayout>
<RadioButton android:id="@+id/radio_setting" style="@style/Ptas_Tab_Bottom" android:layout_marginTop="2.0dip" android:text="文字一" />
</RadioGroup>
</LinearLayout>
2.代码控制切换GroupRadio
private void mainBtnGroupOnclick() {
mainBtnGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (navigaionBtn.getId() == checkedId) {
tabHost.setCurrentTab(1);
} else if (varyBtn.getId() == checkedId) {
tabHost.setCurrentTab(2);
} else if (doingBtn.getId() == checkedId) {
tabHost.setCurrentTab(3);
} else if (settingBtn.getId() == checkedId) {
tabHost.setCurrentTab(5);
}
if (checkedId != noticeBtn.getId()) {
noticeBtn.setChecked(false);
noticeBtn.setFocusableInTouchMode(false);
}
}
});
navigaionBtn.setOnClickListener(this);
varyBtn.setOnClickListener(this);
doingBtn.setOnClickListener(this);
noticeBtn.setOnClickListener(this);
settingBtn.setOnClickListener(this);
}
@Override
public void onClick(View view) {
if (view.getId() == noticeBtn.getId()) {
noticeBtn.setBackgroundResource(R.drawable.home_btn_bg_d);
navigaionBtn.setChecked(false);
doingBtn.setChecked(false);
varyBtn.setChecked(false);
settingBtn.setChecked(false);
settingBtn.setFocusableInTouchMode(false);
varyBtn.setFocusableInTouchMode(false);
doingBtn.setFocusableInTouchMode(false);
navigaionBtn.setFocusableInTouchMode(false);
tabHost.setCurrentTab(4);
} else {
noticeBtn.setBackgroundColor(android.R.color.transparent);
}
}
3.更新数字
Handler myHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case Main.NOTICE_COUNTER_MESSAGE_WHAT:
int counter = msg.getData().getInt("counter", 0);
if (counter == 0) {
noticeCountText.setVisibility(View.GONE);
} else {
noticeCountText.setText("" + counter);
noticeCountText.setVisibility(View.VISIBLE);
}
break;
}
super.handleMessage(msg);
}
};
private void updateNoticeCounter() {
new Thread(new Runnable() {
@Override
public void run() {
while (!Thread.currentThread().isInterrupted()) {
Message message = new Message();
message.what = Main.NOTICE_COUNTER_MESSAGE_WHAT;
Bundle data = new Bundle();
data.putInt("counter", NoticeHolder.getNoticeInfos().size());
message.setData(data);
myHandler.sendMessage(message);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
}).start();
}
- 大小: 4.9 KB
分享到:
相关推荐
android实现类似iPhone的badge未读消息提示,动态改变android桌面icon上的红色气泡
Android 实现 类似于 iPhone 滚桶控件
Android中实现Iphone样式的AlertDialog.rar
类似iphone的android版本的选择时间,会有时间框选择,很实用,一个小工具,大家可以借鉴,很方便
仿iphone界面的从底部弹出来的自定义菜单,可以按照自己需要增加菜单项,美化菜单界面
类似Iphone AssistiveTouch的快捷键按钮
1.实现类似于ios的dialog.iphone的Dialog 2.可以传递参数 IosDialog iosDialog = new IosDialog(MainActivity.this); ArrayList<SheetItem> listSheetItems;
Android实现iphone圆角ListView和点击的效果 Android实现iphone圆角ListView和点击的效果
仿造iPhone dTableView 接口开发的Android TableGroupView
android实现仿iphone滑动解锁demo 再凑几个字
在Android中实现Iphone样式的AlertDialog; 使用Dialog实现。
Android手机实现 iphone qq在线。对于装B一组绝对好用,可以下载试试看!
VC实现的类似IPHONE的软键盘,采用图片双缓冲交叠显示,支持键盘换肤扩展
Android 实现Iphone PickerView 大滚轮效果 实现效果很有新意,可以大大增强用户体验
这是一个android上类似iphone上的开关按钮,希望能对有需要的朋友点帮助。谢谢大家的支持!
android的彷Iphone界面,自定义View
实现类似于iphone手机桌面图片切换效果,简单使用!
见过的android中仿iphone最好的控件,实现下拉刷新 上提加载等功能
Android tabs at bottom! This repository contains sample of setting android TabLayout at bottom and showing Fragment embedded in ViewPager. The magic happens very simply. You need to arrange them ...
想要感受最新iPhone X 或者替代坏掉的 home 键? 这个应用可以添加类似 iPhone X 的 Home 键到你的屏幕。 这个 Home 键非常简单。只有上划,左划或者右划三个动作来启动所选择的动作。