Skip to content

Commit bbf0491

Browse files
committed
Added warning method
1 parent 7fdbd54 commit bbf0491

File tree

5 files changed

+265
-17
lines changed

5 files changed

+265
-17
lines changed

.idea/workspace.xml

Lines changed: 154 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/github/pierry/simpletoast/SimpleToast.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,39 @@ public static void muted(Context context, String msg) {
165165
mytoast.show();
166166
}
167167

168+
public static void warning(Context context, String msg) {
169+
LayoutInflater myInflater = LayoutInflater.from(context);
170+
View view = myInflater.inflate(R.layout.toast_warning, null);
171+
172+
Button button = (Button) view.findViewById(R.id.button);
173+
button.setText(msg);
174+
175+
Toast mytoast = new Toast(context);
176+
177+
mytoast.setView(view);
178+
mytoast.setDuration(Toast.LENGTH_SHORT);
179+
mytoast.show();
180+
}
181+
182+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void warning(Context context, String msg,
183+
String icon) {
184+
LayoutInflater myInflater = LayoutInflater.from(context);
185+
View view = myInflater.inflate(R.layout.toast_warning_icon, null);
186+
187+
Button button = (Button) view.findViewById(R.id.button);
188+
button.setText(msg);
189+
190+
IconTextView img = (IconTextView) view.findViewById(R.id.img);
191+
img.setText(icon);
192+
img.setTextSize(20);
193+
194+
Toast mytoast = new Toast(context);
195+
196+
mytoast.setView(view);
197+
mytoast.setDuration(Toast.LENGTH_SHORT);
198+
mytoast.show();
199+
}
200+
168201
private static Button getButtonInstance() {
169202
mButton = (Button) mView.findViewById(R.id.button);
170203
return mButton;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shape="rectangle" >
4+
<corners android:radius="4dp" />
5+
<stroke
6+
android:width="1dip"
7+
android:color="#B28500" />
8+
<solid android:color="#663300" />
9+
</shape>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:id="@+id/layout"
4+
android:layout_width="wrap_content"
5+
android:layout_height="wrap_content"
6+
android:background="@drawable/list_border_back_yellow" >
7+
8+
<ImageView
9+
android:id="@+id/img"
10+
android:layout_width="wrap_content"
11+
android:layout_height="wrap_content"
12+
android:layout_marginBottom="4dp"
13+
android:layout_marginLeft="4dp"
14+
android:layout_marginTop="4dp"
15+
android:background="@drawable/ok"
16+
android:src="@drawable/ok" />
17+
18+
<Button
19+
android:id="@+id/button"
20+
android:layout_width="wrap_content"
21+
android:layout_height="wrap_content"
22+
android:layout_gravity="center_vertical"
23+
android:layout_marginLeft="8dp"
24+
android:layout_marginRight="13dp"
25+
android:layout_toRightOf="@+id/img"
26+
android:background="@android:color/transparent"
27+
android:paddingBottom="10dp"
28+
android:paddingLeft="10sp"
29+
android:paddingRight="10sp"
30+
android:paddingTop="10dp"
31+
android:text="Texto"
32+
android:textColor="#FFFFFF"
33+
android:textSize="14sp" />
34+
35+
</LinearLayout>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:id="@+id/layout"
4+
android:layout_width="wrap_content"
5+
android:layout_height="wrap_content"
6+
android:background="@drawable/list_border_back_yellow" >
7+
8+
<IconTextView
9+
android:layout_height="fill_parent"
10+
android:layout_width="wrap_content"
11+
android:id="@+id/img"
12+
android:layout_marginBottom="15dp"
13+
android:layout_marginLeft="10dp"
14+
android:textColor="@color/white"
15+
android:layout_marginTop="15dp" />
16+
17+
<Button
18+
android:id="@+id/button"
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:layout_gravity="center_vertical"
22+
android:layout_marginLeft="8dp"
23+
android:layout_marginRight="13dp"
24+
android:layout_toRightOf="@+id/img"
25+
android:background="@android:color/transparent"
26+
android:paddingBottom="10dp"
27+
android:paddingLeft="10sp"
28+
android:paddingRight="10sp"
29+
android:paddingTop="10dp"
30+
android:text="Texto"
31+
android:textColor="#FFFFFF"
32+
android:textSize="14sp" />
33+
34+
</LinearLayout>

0 commit comments

Comments
 (0)