How to clear or hide an ImageView in Android
// solution 1
ImageView imageView = (ImageView)findViewById(R.id.myimage);
imageView.setImageDrawable(null);
// or
imageView.setImageResource(0);
// solution 2 hide ImageView
imageView.setVisibility(View.INVISIBLE);
// solution 3 resize ImageView 0, 0
hImageViewSemafor.setLayoutParams(new LinearLayout.LayoutParams(0,0));
396LW NO topic_id
AD
Další témata ....(Topics)
Get key by value from Map Java Android example
MainClass.java
MainClass.java
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
public class MainClass {
public static void main(String[] arg) {
// english;germany dictionary
String[] arrayOfString = { "one;eine", "two;zwei", "two sets of;zwei"
, "three;drei", "four;vier" };
Map<String, String> map = new TreeMap<String, String>();
for (String s : arrayOfString) {
String[] array = s.split(";");
String sKey = "", sValue = "";
if (array.length > 1) {
sKey = array[0];
sValue = array[1];
map.put(sKey, sValue);
}
}
if (map.containsValue("zwei")) {
Set<String> references = getKeysByValue(map, "zwei");
Iterator<String> it = references.iterator();
while (it.hasNext()) {
String key = (String) it.next();
String value = map.get(key);
System.out.println(key + " = " + value);
}
}
}
public static <T, E> Set<T> getKeysByValue(Map<T, E> map, E value) {
Set<T> keys = new HashSet<T>();
for (Entry<T, E> entry : map.entrySet()) {
if (entry.getValue().equals(value)) {
keys.add(entry.getKey());
}
}
return keys;
}
}
/*
two = zwei
two sets of = zwei
*/
Insert into your default start up activity tag inten-filter tag with action MAIN and category LAUNCHER
AndroidManifest.xml
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="//schemas.android.com/apk/res/android"
package="com.example.blabol"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
If a button have focus, marquee will run.
Important:
android:singleLine="true"
android:ellipsize="marquee"
Optional:
android:marqueeRepeatLimit="1"
Important:
android:singleLine="true"
android:ellipsize="marquee"
Optional:
android:marqueeRepeatLimit="1"
// main.xml
<Button
android:layout_width="150dip"
android:layout_height="wrap_content"
android:text="My button with a long text for marquee as a example source code"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="1"/>
If on Android emulator home button pressed.
Diagram of Activity lifecycle if button HOME pressed
// button home presssed
19:37:06.727: INFO/ActivityManager(60): Starting:
Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME]
flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher } from pid 60
19:37:06.807: INFO/onSaveInstanceState(339): onSaveInstanceState()
19:37:06.848: INFO/onPause(339): onPause()
19:37:07.968: INFO/onStop(339): onStop()
Diagram of Activity lifecycle if button HOME pressed
Check your xml files in Eclipse Graphical Editor and fix problems.
Check project setup, right click on project, select properties, Java build path and
select correct Android version etc.
Right click on project, Android Tools, Fix Project Properties
Menu Eclipse select Project ->Clean.
Check project setup, right click on project, select properties, Java build path and
select correct Android version etc.
Right click on project, Android Tools, Fix Project Properties
Menu Eclipse select Project ->Clean.
Editace: 2013-12-09 13:07:42
Počet článků v kategorii: 396
Url:how-to-clear-or-hide-an-imageview-in-android