Guest User

Untitled

a guest
Oct 27th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. import android.app.Activity;
  2. import android.app.ProgressDialog;
  3. import android.content.Context;
  4. import android.os.Bundle;
  5. import android.view.LayoutInflater;
  6. import android.view.View;
  7. import android.widget.Button;
  8. import android.widget.TextView;
  9. import android.widget.Toast;
  10.  
  11. public class CancelProgressDialog extends Activity {
  12.  
  13. ProgressDialog myProgressDialog = null;
  14.  
  15. @Override
  16. public void onCreate(Bundle icicle) {
  17.  
  18. super.onCreate(icicle);
  19.  
  20. /* Create a very simple button */
  21.  
  22. Button b = new Button(this);
  23.  
  24. this.setContentView(b);
  25.  
  26. b.setText("Show ProgressBar...");
  27.  
  28. // b.setOnClickListener(myProgressBarShower);
  29. Context context = getApplicationContext();
  30.  
  31. LayoutInflater inflater = getLayoutInflater();
  32.  
  33. View toastRoot = inflater.inflate(R.layout.customtoast, null);
  34. TextView tv = (TextView) toastRoot.findViewById(R.id.toasttext);
  35. tv.setWidth(200);
  36. tv.setHeight(100);
  37.  
  38. Toast toast = new Toast(context);
  39.  
  40. toast.setView(toastRoot);
  41. toast.show();
  42. // toast.setText("I am toast");
  43. toast.setDuration(Toast.LENGTH_LONG);
  44.  
  45.  
  46. }
  47. }
  48.  
  49. <?xml version="1.0" encoding="utf-8"?>
  50.  
  51.  
  52. <TextView
  53. xmlns:android="http://schemas.android.com/apk/res/android"
  54. android:layout_width="wrap_content"
  55. android:layout_height="wrap_content"
  56. android:text="I am toast"
  57. android:textColor="#000000"
  58. android:id="@+id/toasttext"
  59. android:background="#ffffff" />
  60.  
  61. Toast t = Toast.makeText(this, "Hello", Toast.LENGTH_SHORT);
  62. t.setGravity(Gravity.FILL_HORIZONTAL, 0, 0);
  63.  
  64. <?xml version="1.0" encoding="utf-8"?>
  65. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  66. android:orientation="vertical"
  67. android:layout_width="wrap_content"
  68. android:layout_height="wrap_content"
  69. android:layout_gravity="center"
  70. android:id="@+id/container"
  71. android:background="@color/white">
  72.  
  73. <!-- customize your width and height here -->
  74. <LinearLayout
  75. android:layout_width="200dp"
  76. android:layout_height="200dp"
  77. android:orientation="vertical"
  78. android:gravity="center">
  79. <ImageView
  80. android:layout_width="wrap_content"
  81. android:layout_height="wrap_content"
  82. android:background="@drawable/ic_check_box"/>
  83. <TextView
  84. android:layout_width="wrap_content"
  85. android:layout_height="wrap_content"
  86. android:text="@string/message"/>
  87. </LinearLayout>
  88. </LinearLayout>
Add Comment
Please, Sign In to add comment