Trabla: Android Toast - popup messages
Solving:
Toast - a small popup with feedback. Automatically disappear after a timeout.
Toast toast = Toast.makeText(this,
"toast message text", Toast.LENGTH_LONG);
toast.show();
Predefined hardcoded delays ( !!!Can't be changed!!!):
private static final int LONG_DELAY = 3500; // 3.5 seconds
private static final int SHORT_DELAY = 2000; // 2 seconds
Hack to show more than predefined timeouts
for (int i=0; i < 2; i++)
{
Toast.makeText(this, "toast message text", Toast.LENGTH_LONG).show();
}
Showing posts with label ADT. Show all posts
Showing posts with label ADT. Show all posts
Android & ADT: project resources types
Trabla: Adroid Developer Tools project resources explanation ( folder "res/values")
Solving:
In ADT project in folder "res/values" we place .xml files with description of resources.
Name of file doesn't matters - e.g. "caramba.xml" is OK.
Mandatory content for .xml resource file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Put resource tags here -->
</resources>
Resourses Types:
-----------------
1.Bool
-----------------
Tag in resource file
<bool name="my_true_bool">true</bool>
----------
Use in layout xml
android:adjustViewBounds="@bool/my_true_bool"
----------
Use in code -
Resources res = getResources();
boolean myBool= res.getBoolean( R.bool.my_true_bool );
-----------------
2. Color
-----------------
Tag in resource file
<color name="my_color">#ffB6FF00</color >
----------
Use in layout xml
android:background="@color/my_color"
----------
Use in code -
Resources res = getResources();
int myColor = res.getColor( R.color.my_color );
-----------------
3. Dimenstion
-----------------
4.ID
-----------------
5.Integer
-----------------
6.Integer Array
-----------------
7. Typed Array
-----------------
We can place different types of resources in one .xml resource file, but best practice is to create separate file for one type.
Example: file "caramba.xml" in folder "res/values"
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Put resource tags here -->
<!-- My Bools-->
<bool name="my_true_bool">true</bool>
<bool name="my_false_bool">false</bool >
<!-- My Colors -->
<color name="my_color">#ffB6FF00</color >
<color name="my_second_color">#ffff0000</color >
</resources>
Solving:
In ADT project in folder "res/values" we place .xml files with description of resources.
Name of file doesn't matters - e.g. "caramba.xml" is OK.
Mandatory content for .xml resource file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Put resource tags here -->
</resources>
Resourses Types:
-----------------
1.Bool
-----------------
Tag in resource file
<bool name="my_true_bool">true</bool>
----------
Use in layout xml
android:adjustViewBounds="@bool/my_true_bool"
----------
Use in code -
Resources res = getResources();
boolean myBool= res.getBoolean( R.bool.my_true_bool );
-----------------
2. Color
-----------------
Tag in resource file
<color name="my_color">#ffB6FF00</color >
----------
Use in layout xml
android:background="@color/my_color"
----------
Use in code -
Resources res = getResources();
int myColor = res.getColor( R.color.my_color );
-----------------
3. Dimenstion
-----------------
4.ID
-----------------
5.Integer
-----------------
6.Integer Array
-----------------
7. Typed Array
-----------------
We can place different types of resources in one .xml resource file, but best practice is to create separate file for one type.
Example: file "caramba.xml" in folder "res/values"
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Put resource tags here -->
<!-- My Bools-->
<bool name="my_true_bool">true</bool>
<bool name="my_false_bool">false</bool >
<!-- My Colors -->
<color name="my_color">#ffB6FF00</color >
<color name="my_second_color">#ffff0000</color >
</resources>
Subscribe to:
Posts (Atom)