Not request focus EditText if startup Android
Not request focus EditText if startup Android - hide keyboard if startup.
Remove: from EditText
Create a LinearLayout and set the:
attributes android:focusable="true" android:focusableInTouchMode="true"
Remove:
Create a LinearLayout and set the:
attributes android:focusable="true" android:focusableInTouchMode="true"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical" >
</LinearLayout>
396LW NO topic_id
AD
Další témata ....(Topics)
Select file in project explorer
Menu:
File - Make File Read-only - to lock
File - Make File Writable - to unlock
Menu:
File - Make File Read-only - to lock
File - Make File Writable - to unlock
LayoutLib is too recent. Update your tool!
Eclipse Android Graphical layout resolving problem.
Eclipse Android Graphical layout resolving problem.
- Open in Eclipse menu Help ->Check for Updates
- Select updates:
- Press Next and update all
- Restart Eclipse
[caption id="attachment_596" align="alignleft" width="300" caption="Restart Eclipse if updates finished."][/caption]
Android app setup preferences, settings, open, read, write, onStop(), onPause(), getSharedPreferences(), SharedPreferences.Editor getInt(), getBoolean(), getString() , putInt(), putString(), putBoolean() example source code.
import android.content.SharedPreferences;
public class MainClass extends Activity {
public static final String PREFERENCES_NAME = "MyPrefsFile";
String myNewString;
int myNewInt;
Boolean myNewBool;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// read old settings if exist
SharedPreferences settings = getSharedPreferences(PREFERENCES_NAME, 0);
String sDefault = "Hello!";
String sStringFromPrefFile = settings.getString("myString", sDefault); // new text or default Hello!
int nDefaultIndex = 2; //
int nIndexFromPrefFile = settings.getInt("myInt", nDefaultIndex); // 4 or default 2
Boolean bDefault = false;
Boolean bFromPrefFile = settings.getBoolean("silentMode", bDefault); // true or default false
// new settings will saved in onStop or onPause
myNewString = "new text";
myNewInt = 4;
myNewBool = true;
}
@Override
protected void onPause() {
super.onPause();
Toast.makeText(getApplicationContext(), "onPause "
, Toast.LENGTH_SHORT).show();
savePreferences();
}
@Override
protected void onStop() {
super.onStop();
savePreferences();
}
/**save settings*/
public void savePreferences(){
try {
SharedPreferences settings = getSharedPreferences(PREFERENCES_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("myString", myNewString);
editor.putInt("nMyInt", myNewInt);
editor.putBoolean("silentMode", myNewBool); //
editor.commit();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Toast in Android application is equivalent of Alert in JavaScript or MessageBox in WinApi.
// Toast android.widget.Toast.makeText(Context context, CharSequence text, int duration)
// public static Toast makeText (Context context, CharSequence text, int duration)
Toast.makeText(getApplicationContext(), "Hello world!",
Toast.LENGTH_SHORT).show();
private int _nVersionCode = 0;
private boolean _bNewVersion = false;
// onCreate
_nVersionCode = this.getPackageManager()
.getPackageInfo(this.getPackageName(), 0).versionCode;
Log.d(String.valueOf(_nVersionCode), "versionCode");
// onStart loadPreferences
public void loadPreferences() {
//SharedPreferences settings = getSharedPreferences(F.PREFERENCES_NAME, 0);
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
int nOldVersionCode = settings.getInt("_nVersionCode", 0);// old vesion
if(_nVersionCode > nOldVersionCode)
_bNewVersion = true;
}
// onDestroy savePreferences
public void savePreferences() {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("_nVersionCode", _nVersionCode); // save current version code
editor.commit();
}
Editace: 2013-02-01 16:57:04
Počet článků v kategorii: 396
Url:not-request-focus-edittext-if-startup-android