Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. public class MainActivity extends Activity implements CordovaInterface{
  2. .....
  3. .....
  4. public void changeText(String txt){
  5. textView = (TextView) findViewById(R.id.textView);
  6. textView.setText(txt);
  7.  
  8. }
  9.  
  10. }
  11.  
  12. public boolean execute(String action, JSONArray args, final CallbackContext callbackContext){
  13. if (action.equals("changeText")) {
  14. ..............
  15. }
  16. }
  17. }
  18.  
  19. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  20. xmlns:tools="http://schemas.android.com/tools"
  21. android:layout_width="match_parent"
  22. android:layout_height="match_parent"
  23. tools:context=".MainActivity" >
  24.  
  25. <org.apache.cordova.CordovaWebView
  26. android:id="@+id/tutorialView"
  27. android:layout_width="match_parent"
  28. android:layout_height="196dp" />
  29.  
  30. <TextView
  31. android:id="@+id/textView"
  32. android:layout_width="wrap_content"
  33. android:layout_height="wrap_content"
  34. android:text="@string/hello_world" />
  35.  
  36. </RelativeLayout>
  37.  
  38. cordova.getActivity().runOnUiThread(new Runnable(){
  39. public void run() {
  40.  
  41. textView.setText("Cordova Hello World");
  42.  
  43. callbackContext.success();
  44.  
  45. // Thread-safe.
  46.  
  47. } });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement