android - RemoteViews now working in View class -


i making custom ui in view class , made remoteviews in working

view class

public class customeview extends view {      bitmap icon;     float left=0;     remoteviews rs;     int width=0,height=0;     float def_value=0;     boolean unlock=false;      public customeview(context context, attributeset attrs) {         super(context, attrs);         icon=bitmapfactory.decoderesource(getresources(), r.drawable.icon);         rs=new remoteviews(context.getpackagename() ,r.layout.custom_ui);          windowmanager wm = (windowmanager) context.getsystemservice(context.window_service);         display display = wm.getdefaultdisplay();         width = display.getwidth();         height = display.getheight();          left=width/2;         def_value=left;     }      @override     protected void ondraw(canvas canvas) {         // todo auto-generated method stub         super.ondraw(canvas);         paint a=new paint();         a.settextsize(10);          canvas.drawbitmap(icon, left, 0, null);         canvas.drawtext(string.valueof(unlock), 0, 110, a);     }      @override     protected void onmeasure(int widthmeasurespec, int heightmeasurespec) {            setmeasureddimension(width, height);     }      @override     public boolean ontouchevent(motionevent event) {         // todo auto-generated method stub         if(event.getaction()==motionevent.action_move){             left=event.getx()-(icon.getwidth()/2);             isunlock();         }         else if (event.getaction()==motionevent.action_up) {             if(def_value!=left){                 left=def_value;             }         }         invalidate();         return true;     }      protected void isunlock() {         if(left<=20){                        unlock=true;             rs.settextviewtext(r.id.tvstatus, "true");         }         if(left>=width-20){             unlock=true;             rs.settextviewtext(r.id.tvstatus, "true");         }     } } 

custom_ui.xml layout

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent">      <com.example.helloworl.customeview          android:id="@+id/icon"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_alignparenttop="true" />      <textview         android:id="@+id/tvstatus"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_alignparenttop="true"         android:layout_marginleft="20dp"         android:layout_margintop="154dp"         android:text="false" />  </relativelayout> 

remoteviews changing value of textview in isunlock method not working. please me solve problem.

you cannot use custom views remoteviews, other process not have access java code.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -