Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. final Activity targetActivity = Solo.getCurrentActivity(); // Using Robotium to get current displayed Activity
  2. Toast.makeText(targetActivity, "Hello from Instrumentation", Toast.LENGTH_SHORT).show();
  3.  
  4. final Activity targetActivity = Solo.getCurrentActivity(); // Using Robotium to get current displayed Activity
  5.  
  6. LayoutInflater inflater = targetActivity.getLayoutInflater();
  7. View layout = inflater.inflate(test.my.package.R.layout.my_custom_toast, null); // resource is located in test project
  8. TextView text = (TextView) layout.findViewById(test.my.package.R.id.textToShow); // textview within the layout
  9.  
  10. text.setText("Hello from Instrumentation"); // here I get the NullPointerException
  11.  
  12. Toast toast = new Toast(targetActivity);
  13. toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
  14. toast.setDuration(Toast.LENGTH_LONG);
  15. toast.setView(layout);
  16. toast.show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement