android5.x Adding SIM1,SIM2 identities

Source: Internet
Author: User

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};
Picture Sim1_indicator,sim2_indicator is the SIM1,SIM2 logo you made
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);
}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

android5.x Adding SIM1,SIM2 identities

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.