android5.x添加sim1,sim2标识
2015-07-07 20:04
537 查看
1,mobile_signal_group.xml
.....
<FrameLayout
android:id="@+id/mobile_combo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/mobile_signal"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<ImageView
android:id="@+id/mobile_type"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<!-- http://blog.csdn.net/sergeycao :mobile_slot_indicateor". }@ -->
<ImageView
android:id="@+id/mobile_slot_indicator"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</FrameLayout>
2,SignalClusterView.java
//http://blog.csdn.net/sergeycao
int mIndicatorSlot=0;
//http://blog.csdn.net/sergeycao end
private ArrayList<PhoneState> mPhoneStates = new ArrayList<PhoneState>();
//http://blog.csdn.net/sergeycao
int[] slots_indicators=new int[]{R.drawable.sim1_indicator,R.drawable.sim2_indicator};
// 图片sim1_indicator,sim2_indicator是你***的sim1,sim2标识
//http://blog.csdn.net/sergeycao end
@Override
public void setSubs(List<SubscriptionInfo> subs) {
Xlog.d(TAG, "setSubs(), subs= " + subs);
// Clear out all old subIds.
mPhoneStates.clear();
if (mMobileSignalGroup != null) {
mMobileSignalGroup.removeAllViews();
}
final int n = subs.size();
for (int i = 0; i < n; i++) {
//http://blog.csdn.net/sergeycao
mIndicatorSlot=subs.get(i).getSimSlotIndex();
//http://blog.csdn.net/sergeycao end
inflatePhoneState(subs.get(i).getSubscriptionId());
}
private PhoneState inflatePhoneState(int subId) {
PhoneState state = new PhoneState(subId, mContext);
//http://blog.csdn.net/sergeycao
state.mSlotIndicator=mIndicatorSlot;
//http://blog.csdn.net/sergeycao end
if (mMobileSignalGroup != null) {
mMobileSignalGroup.http://blog.csdn.net/sergeycaoView(state.mMobileGroup);
}
mPhoneStates.http://blog.csdn.net/sergeycao(state);
return state;
}
private class PhoneState {
private final int mSubId;
private boolean mMobileVisible = false;
private int mMobileStrengthId = 0, mMobileTypeId = 0;
private boolean mIsMobileTypeIconWide;
private String mMobileDescription, mMobileTypeDescription;
private ViewGroup mMobileGroup;
//http://blog.csdn.net/sergeycao
private ImageView mMobile, mMobileType,mMobileSlotIndicator;// http://blog.csdn.net/sergeycao mMobileSlotIndicator
//http://blog.csdn.net/sergeycao
private int mSlotIndicator;
public void setViews(ViewGroup root) {
mMobileGroup = root;
mMobile = (ImageView) root.findViewById(R.id.mobile_signal);
mMobileType = (ImageView) root.findViewById(R.id.mobile_type);
/// M: Support "Service Network Type on Statusbar".
mSignalNetworkType = (ImageView) root.findViewById(R.id.network_type);
// http://blog.csdn.net/sergeycao
mMobileSlotIndicator= (ImageView) root.findViewById(R.id.mobile_slot_indicator);
//http://blog.csdn.net/sergeycao end
}
public boolean apply(boolean isSecondaryIcon) {
Xlog.d(TAG, "apply(" + mSubId + ")," + " mMobileVisible= " + mMobileVisible +
", mIsAirplaneMode= " + mIsAirplaneMode);
if (mMobileVisible && !mIsAirplaneMode) {
mMobile.setImageResource(mMobileStrengthId);
mMobileType.setImageResource(mMobileTypeId);
mMobileGroup.setContentDescription(mMobileTypeDescription
+ " " + mMobileDescription);
mMobileGroup.setVisibility(View.VISIBLE);
//http://blog.csdn.net/sergeycao
mMobileSlotIndicator.setImageResource(slots_indicators[mSlotIndicator]);
//http://blog.csdn.net/sergeycao end
} else {
mMobileGroup.setVisibility(View.GONE);
}
.....
<FrameLayout
android:id="@+id/mobile_combo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/mobile_signal"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<ImageView
android:id="@+id/mobile_type"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<!-- http://blog.csdn.net/sergeycao :mobile_slot_indicateor". }@ -->
<ImageView
android:id="@+id/mobile_slot_indicator"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</FrameLayout>
2,SignalClusterView.java
//http://blog.csdn.net/sergeycao
int mIndicatorSlot=0;
//http://blog.csdn.net/sergeycao end
private ArrayList<PhoneState> mPhoneStates = new ArrayList<PhoneState>();
//http://blog.csdn.net/sergeycao
int[] slots_indicators=new int[]{R.drawable.sim1_indicator,R.drawable.sim2_indicator};
// 图片sim1_indicator,sim2_indicator是你***的sim1,sim2标识
//http://blog.csdn.net/sergeycao end
@Override
public void setSubs(List<SubscriptionInfo> subs) {
Xlog.d(TAG, "setSubs(), subs= " + subs);
// Clear out all old subIds.
mPhoneStates.clear();
if (mMobileSignalGroup != null) {
mMobileSignalGroup.removeAllViews();
}
final int n = subs.size();
for (int i = 0; i < n; i++) {
//http://blog.csdn.net/sergeycao
mIndicatorSlot=subs.get(i).getSimSlotIndex();
//http://blog.csdn.net/sergeycao end
inflatePhoneState(subs.get(i).getSubscriptionId());
}
private PhoneState inflatePhoneState(int subId) {
PhoneState state = new PhoneState(subId, mContext);
//http://blog.csdn.net/sergeycao
state.mSlotIndicator=mIndicatorSlot;
//http://blog.csdn.net/sergeycao end
if (mMobileSignalGroup != null) {
mMobileSignalGroup.http://blog.csdn.net/sergeycaoView(state.mMobileGroup);
}
mPhoneStates.http://blog.csdn.net/sergeycao(state);
return state;
}
private class PhoneState {
private final int mSubId;
private boolean mMobileVisible = false;
private int mMobileStrengthId = 0, mMobileTypeId = 0;
private boolean mIsMobileTypeIconWide;
private String mMobileDescription, mMobileTypeDescription;
private ViewGroup mMobileGroup;
//http://blog.csdn.net/sergeycao
private ImageView mMobile, mMobileType,mMobileSlotIndicator;// http://blog.csdn.net/sergeycao mMobileSlotIndicator
//http://blog.csdn.net/sergeycao
private int mSlotIndicator;
public void setViews(ViewGroup root) {
mMobileGroup = root;
mMobile = (ImageView) root.findViewById(R.id.mobile_signal);
mMobileType = (ImageView) root.findViewById(R.id.mobile_type);
/// M: Support "Service Network Type on Statusbar".
mSignalNetworkType = (ImageView) root.findViewById(R.id.network_type);
// http://blog.csdn.net/sergeycao
mMobileSlotIndicator= (ImageView) root.findViewById(R.id.mobile_slot_indicator);
//http://blog.csdn.net/sergeycao end
}
public boolean apply(boolean isSecondaryIcon) {
Xlog.d(TAG, "apply(" + mSubId + ")," + " mMobileVisible= " + mMobileVisible +
", mIsAirplaneMode= " + mIsAirplaneMode);
if (mMobileVisible && !mIsAirplaneMode) {
mMobile.setImageResource(mMobileStrengthId);
mMobileType.setImageResource(mMobileTypeId);
mMobileGroup.setContentDescription(mMobileTypeDescription
+ " " + mMobileDescription);
mMobileGroup.setVisibility(View.VISIBLE);
//http://blog.csdn.net/sergeycao
mMobileSlotIndicator.setImageResource(slots_indicators[mSlotIndicator]);
//http://blog.csdn.net/sergeycao end
} else {
mMobileGroup.setVisibility(View.GONE);
}
相关文章推荐
- Android studio学习和gradle学习列表
- kernel logo到开机动画之间闪现黑屏(android 5.X)
- Android系统启动流程
- android 通知基础
- 初学_Android4高级编程-6 Intent Filiter &Broadcast Receiver
- 初学_Android4高级编程-5 Intent&Broadcast
- Android编译输出 资源指定AAPT
- android studio 使用细节
- Android各个support library特征和区别(官方文档)
- android源码使用proguard混淆编译及错误总结
- Bitmap基本概念及在Android4.4系统上使用BitmapFactory的注意事项
- 从头学起android<android基本的绘图.四十六.>
- Android 实现个性的ViewPager切换动画 实战PageTransformer(兼容Android3.0以下)
- Android入门(32)——第九章 Fragment与Activity通信
- android中HorizontalScrollView实现viewpager的效果
- Android NDK编程浅入深出之--域和方法的操作
- Android ListView滑动后背景变黑问题解决方法
- Android LayoutInflater原理分析,带你一步步深入了解View(一)
- Android至ViewPager添加切换动画——使用属性动画
- android activity launchmode