java - How to change native element from Phonegap plugin? -
i want alter native textview value pass cordova plugin. application show 2 elements - native element(textview) , cordova webview in 1 activity layout. possible interchange context between main , phonegap update current ui... have 1 idea?...
example concept -
public class mainactivity extends activity implements cordovainterface{ ..... ..... public void changetext(string txt){ textview = (textview) findviewbyid(r.id.textview); textview.settext(txt); } }
cordova plugin:
public class myplugin extends cordovaplugin {
public boolean execute(string action, jsonarray args, final callbackcontext callbackcontext){ if (action.equals("changetext")) { .............. } } }
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" tools:context=".mainactivity" > <org.apache.cordova.cordovawebview android:id="@+id/tutorialview" android:layout_width="match_parent" android:layout_height="196dp" /> <textview android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> </relativelayout>
finally works.... 2 elements of import :
cordova context- phone call textview in plugin class using:textview textview = cordova.getactivity().findviewbyid(r.id.textview);
eg:-
cordova.getactivity().runonuithread(new runnable(){ public void run() { textview.settext("cordova hello world"); callbackcontext.success(); // thread-safe. } });
java android cordova phonegap-plugins
No comments:
Post a Comment