android - inflateexeption : binary xml file line 31 (use patternview in overlyview) -
sorry bad english . want use pattern view in overly view .
public class patternoverlayview extends overlayview implements patternview.onpatternlistener{ private cameragesturesensor mgesturesensor; private boolean mopencvinitiated = false; private final static string format_12_hours = "hh:mm"; private final static string format_24_hours = "kk:mm"; private string mtimeformat; private string mdateformat; private calendar mcalendar; private string mam, mpm; private string mdayformat; private string moformat; numberpicker np,np1,np2 ; static textview tim; static textview month; static textview dayt; static textview salt; static textview roozt; static textview chargelevel; static textview am; private static final string tag = "practicegesturesactivity"; //private direction mcurrentdirection; sharedpreferences getload ; activity acti ; relativelayout ivloader ; animationdrawable frameanimation; private gesturedetector mgesture; relativelayout topvi ; private static final string key_num_failed_attempts = "num_failed_attempts"; protected textview messagetext; protected patternview patternview; protected linearlayout buttoncontainer; protected button leftbutton; protected button rightbutton; protected int numfailedattempts; public patternoverlayview(bestservice service,activity ac,view vi) { super(service, r.layout.patternlock, 1,ac,vi); acti = ac ; /**window window = ac.getwindow(); window.addflags(windowmanager.layoutparams.flag_show_when_locked | windowmanager.layoutparams.flag_keep_screen_on); */ } public int getgravity() { return gravity.top + gravity.right; } @override public void onpatternstart() { removeclearpatternrunnable(); // set display mode correct ensure pattern can in stealth mode. patternview.setdisplaymode(patternview.displaymode.correct); } @override public void onpatterncelladded(list<patternview.cell> pattern) {} @override public void onpatterndetected(list<patternview.cell> pattern) { if (ispatterncorrect(pattern)) { onconfirmed(); } else { //messagetext.settext(r.string.pl_wrong_pattern); patternview.setdisplaymode(patternview.displaymode.wrong); postclearpatternrunnable(); //viewaccessibilitycompat.announceforaccessibility(messagetext, messagetext.gettext()); onwrongpattern(); } } @override public void onpatterncleared() { removeclearpatternrunnable(); } protected boolean isstealthmodeenabled() { return false; } protected boolean ispatterncorrect(list<patternview.cell> pattern) { return true; } protected void onconfirmed() { // setresult(result_ok); // finish(); } protected void onwrongpattern() { // ++numfailedattempts; } protected void oncancel() { // setresult(result_canceled); // finish(); } protected void onforgotpassword() { // setresult(result_forgot_password); // finish(); } private final runnable clearpatternrunnable = new runnable() { public void run() { // clearpattern() resets display mode displaymode.correct. patternview.clearpattern(); } }; protected void removeclearpatternrunnable() { patternview.removecallbacks(clearpatternrunnable); } protected void postclearpatternrunnable() { removeclearpatternrunnable(); patternview.postdelayed(clearpatternrunnable, 2000); } private void endoflock() { vibrator v = (vibrator) getcontext().getsystemservice(context.vibrator_service); // vibrate 500 milliseconds v.vibrate(300); activity ac = serializ.activity; ac.finish(); if (getload.getboolean("animstatuse", false) == true) frameanimation.stop(); //getcontext().stopservice(new intent(updateservice.action_update)); intent intent = new intent(getcontext(), sampleoverlayhideactivity.class); intent.setflags(intent.flag_activity_new_task); getcontext().startactivity(intent); } @suppresswarnings("deprecation") @override protected void oninflateview() { messagetext = (textview)findviewbyid(r.id.pl_message_text); patternview = (patternview)findviewbyid(r.id.pl_pattern); buttoncontainer = (linearlayout)findviewbyid(r.id.pl_button_container); leftbutton = (button)findviewbyid(r.id.pl_left_button); rightbutton = (button)findviewbyid(r.id.pl_right_button); messagetext.settext(r.string.pl_draw_pattern_to_unlock); patternview.setinstealthmode(isstealthmodeenabled()); patternview.setonpatternlistener(this); leftbutton.settext(r.string.pl_cancel); leftbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { oncancel(); } }); rightbutton.settext(r.string.pl_forgot_pattern); rightbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { onforgotpassword(); } }); viewaccessibilitycompat.announceforaccessibility(messagetext, messagetext.gettext()); ontouchlistener swiplisen = new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { // todo auto-generated method stub return mgesture.ontouchevent(event); } }; /** tim = (textview) this.findviewbyid(r.id.time); tim.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub endoflock(); } }); month = (textview) findviewbyid(r.id.date); dayt = (textview) findviewbyid(r.id.day); salt = (textview) findviewbyid(r.id.sal); roozt = (textview) findviewbyid(r.id.rooz); = (textview) findviewbyid(r.id.am_pm); chargelevel = (textview)findviewbyid(r.id.chargetext); getcontext().startservice(new intent(updateservice.action_update)); setsystemuivisibility(view.system_ui_flag_immersive_sticky); // np = (numberpicker) findviewbyid(r.id.numberpicker1); // np1 = (numberpicker) findviewbyid(r.id.numberpicker2); // np2 = (numberpicker) findviewbyid(r.id.numberpicker3); // np.setmaxvalue(9); // np.setminvalue(0); // np.setfocusable(true); // np.setfocusableintouchmode(true); // np1.setmaxvalue(9); // np1.setminvalue(0); // np1.setfocusable(true); // np1.setfocusableintouchmode(true); // np2.setmaxvalue(9); // np2.setminvalue(0); // np2.setfocusable(true); // np2.setfocusableintouchmode(true); // todo auto-generated method stub getload = getcontext().getsharedpreferences("ir.lockscreen.ir", getcontext().mode_private); ivloader = (relativelayout) findviewbyid(r.id.vie); topvi = (relativelayout) findviewbyid(r.id.topview); int unspace = getresources().getdimensionpixelsize(r.dimen.unlockspace); final float toplayotx = topvi.getx(); final int toplayotwidth = (getscreenwidth()/2)-unspace; topvi.setontouchlistener(new onswipetouchlistener(getcontext()) { boolean = false ; @override public void onswiperight(float dx) { // whatever if (viewhelper.gettranslationx(topvi)>(toplayotwidth)) { = true ; } else viewhelper.settranslationx(topvi, topvi.getx() + dx); } @override public void onup() { // whatever //toast.maketext(getcontext(), "left", toast.length_long).show(); if(a==true) {viewhelper.settranslationx(topvi, getscreenwidth()); a=false; endoflock(); } else viewhelper.settranslationx(topvi, toplayotx); } }); new asynccaller().execute(); // np.setonvaluechangedlistener(new numberpicker.onvaluechangelistener() { // @override // public void onvaluechange(numberpicker picker, int oldval, int newval) { // todo auto-generated method stub // if (newval == 4) // { // toast.maketext(getcontext(), "shod", toast.length_short).show(); // intent intent = new intent(getcontext(), sampleoverlayhideactivity.class); // intent.setflags(intent.flag_activity_new_task); // getcontext().startactivity(intent); // } // } //}); */ } protected int getscreenwidth() { displaymetrics displaymetrics = new displaymetrics(); windowmanager windowmanager = (windowmanager) getcontext().getsystemservice(context.window_service); windowmanager.getdefaultdisplay().getmetrics(displaymetrics); int height = displaymetrics.heightpixels; int width = displaymetrics.widthpixels; return width; } @override protected void refreshviews() { // info.settext("waiting\nwaiting"); } @override protected void ontouchevent_up(motionevent event) { //info.settext("up\npointers: " + event.getpointercount()); } @override protected void ontouchevent_move(motionevent event) { // info.settext("move\npointers: " + event.getpointercount()); } @override protected void ontouchevent_press(motionevent event) { //info.settext("down\npointers: " + event.getpointercount()); } @override public boolean ontouchevent_longpress() { // info.settext("long\npress"); return true; }
and xml load view :
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:divider="?android:attr/dividerhorizontal" android:orientation="vertical" android:showdividers="middle"> <textview android:id="@+id/pl_message_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:minheight="?android:attr/listpreferreditemheight" android:gravity="center" android:textappearance="?android:attr/textappearancemedium" /> <!-- framelayout proper divider drawing. --> <framelayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:padding="16dp"> <me.zhanghai.patternlock.patternview android:id="@+id/pl_pattern" android:layout_width="match_parent" android:layout_height="match_parent" /> </framelayout> <linearlayout android:id="@+id/pl_button_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:divider="?android:attr/dividervertical" android:dividerpadding="12dp" android:showdividers="middle"> <button android:id="@+id/pl_left_button" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" style="?android:attr/borderlessbuttonstyle" /> <button android:id="@+id/pl_right_button" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" style="?android:attr/borderlessbuttonstyle" /> </linearlayout>
and error :
06-04 10:26:43.363: w/resourcetype(1356): no package identifier when getting value resource number 0x00000000 06-04 10:26:43.363: w/resourcetype(1356): no package identifier when getting value resource number 0x00000000 06-04 10:26:43.363: w/resourcetype(1356): no package identifier when getting value resource number 0x00000000 06-04 10:26:43.363: w/resourcetype(1356): no package identifier when getting value resource number 0x00000000 06-04 10:26:43.367: w/resourcetype(1356): no package identifier when getting value resource number 0x00000000 06-04 10:26:43.375: d/androidruntime(1356): shutting down vm 06-04 10:26:43.375: w/dalvikvm(1356): threadid=1: thread exiting uncaught exception (group=0xa4c06648) 06-04 10:26:43.391: e/androidruntime(1356): fatal exception: main 06-04 10:26:43.391: e/androidruntime(1356): java.lang.runtimeexception: unable start service ir.rn.lockscreen.bestservice@52a5a95c intent {cmp=ir.rn.lockscreen/.bestservice }: android.view.inflateexception: binary xml file line #31: error inflating class me.zhanghai.patternlock.patternview 06-04 10:26:43.391: e/androidruntime(1356): @ android.app.activitythread.handleserviceargs(activitythread.java:2721) 06-04 10:26:43.391: e/androidruntime(1356): @ android.app.activitythread.access$1900(activitythread.java:141) 06-04 10:26:43.391: e/androidruntime(1356): @ android.app.activitythread$h.handlemessage(activitythread.java:1353) 06-04 10:26:43.391: e/androidruntime(1356): @ android.os.handler.dispatchmessage(handler.java:99) 06-04 10:26:43.391: e/androidruntime(1356): @ android.os.looper.loop(looper.java:137) 06-04 10:26:43.391: e/androidruntime(1356): @ android.app.activitythread.main(activitythread.java:5103) 06-04 10:26:43.391: e/androidruntime(1356): @ java.lang.reflect.method.invokenative(native method) 06-04 10:26:43.391: e/androidruntime(1356): @ java.lang.reflect.method.invoke(method.java:525) 06-04 10:26:43.391: e/androidruntime(1356): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737) 06-04 10:26:43.391: e/androidruntime(1356): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 06-04 10:26:43.391: e/androidruntime(1356): @ dalvik.system.nativestart.main(native method) 06-04 10:26:43.391: e/androidruntime(1356): caused by: android.view.inflateexception: binary xml file line #31: error inflating class me.zhanghai.patternlock.patternview 06-04 10:26:43.391: e/androidruntime(1356): @ android.view.layoutinflater.createview(layoutinflater.java:620) 06-04 10:26:43.391: e/androidruntime(1356): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:696) 06-04 10:26:43.391: e/androidruntime(1356): @ android.view.layoutinflater.rinflate(layoutinflater.java:755) 06-04 10:26:43.391: e/androidruntime(1356): @ android.view.layoutinflater.rinflate(layoutinflater.java:758) 06-04 10:26:43.391: e/androidruntime(1356): @ android.view.layoutinflater.inflate(layoutinflater.java:492) 06-04 10:26:43.391: e/androidruntime(1356): @ android.view.layoutinflater.inflate(layoutinflater.java:397) 06-04 10:26:43.391: e/androidruntime(1356): @ android.view.layoutinflater.inflate(layoutinflater.java:353) 06-04 10:26:43.391: e/androidruntime(1356): @ ir.rn.lockscreen.overlayview.inflateview(overlayview.java:96) 06-04 10:26:43.391: e/androidruntime(1356): @ ir.rn.lockscreen.overlayview.load(overlayview.java:143) 06-04 10:26:43.391: e/androidruntime(1356): @ ir.rn.lockscreen.overlayview.<init>(overlayview.java:62) 06-04 10:26:43.391: e/androidruntime(1356): @ ir.rn.lockscreen.patternoverlayview.<init>(patternoverlayview.java:112) 06-04 10:26:43.391: e/androidruntime(1356): @ ir.rn.lockscreen.bestservice.onstartcommand(bestservice.java:50) 06-04 10:26:43.391: e/androidruntime(1356): @ android.app.activitythread.handleserviceargs(activitythread.java:2704) 06-04 10:26:43.391: e/androidruntime(1356): ... 10 more 06-04 10:26:43.391: e/androidruntime(1356): caused by: java.lang.reflect.invocationtargetexception 06-04 10:26:43.391: e/androidruntime(1356): @ java.lang.reflect.constructor.constructnative(native method) 06-04 10:26:43.391: e/androidruntime(1356): @ java.lang.reflect.constructor.newinstance(constructor.java:417) 06-04 10:26:43.391: e/androidruntime(1356): @ android.view.layoutinflater.createview(layoutinflater.java:594) 06-04 10:26:43.391: e/androidruntime(1356): ... 22 more 06-04 10:26:43.391: e/androidruntime(1356): caused by: java.lang.nullpointerexception 06-04 10:26:43.391: e/androidruntime(1356): @ me.zhanghai.patternlock.patternview.<init>(patternview.java:299) 06-04 10:26:43.391: e/androidruntime(1356): @ me.zhanghai.patternlock.patternview.<init>(patternview.java:260) 06-04 10:26:43.391: e/androidruntime(1356): ... 25 more
when use patternview in activity , set theme activity dont have problem , when use in overlyview error
@reza in opinion should include following item in theme editing style.xml file :
<item name="patternviewstyle">@style/patternview.holo</item>
as mentioned zhang hai here: https://github.com/dreamingincodezh/patternlock#styling
it worked me. :)
Comments
Post a Comment