码迷,mamicode.com
首页 > 移动开发 > 详细

android5.x加入sim1,sim2标识

时间:2017-06-17 16:05:58      阅读:301      评论:0      收藏:0      [点我收藏+]

标签:text   div   visible   esc   amp   制作   msi   roi   .net   

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);
}

android5.x加入sim1,sim2标识

标签:text   div   visible   esc   amp   制作   msi   roi   .net   

原文地址:http://www.cnblogs.com/yutingliuyl/p/7040241.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!