Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

EditText text changed java Android


AD MOB

Google Android example source code - is text changed in EditText ?

EditText hEditText;

// TextChanged in onCreate
hEditText = (EditText)findViewById(R.id.idEditText);
hEditText.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable str) {
}

public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}

public void onTextChanged(CharSequence sq, int start, int before,
int count) {
}
});

397LW NO topic_id




AD

Další témata ....(Topics)


372

ListView set the item as checked to be highlighted | listview-set-the-item-as-checked-to-be-highlighted


Important: Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB

int layout = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ?
android.R.layout.simple_list_item_activated_1 :
android.R.layout.simple_list_item_1;


getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
getListView().setItemChecked(position, true);


Example of usage:


public void updateList() {
		Context ctx = getActivity();
		Notes notes = new Notes(ctx);

		String[] from = { Notes.COLUMN_TITLE };
		int[] to = { android.R.id.text1 };
		int layout = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ?
				android.R.layout.simple_list_item_activated_1 : android.R.layout.simple_list_item_1;
		ListAdapter adapter = new SimpleCursorAdapter(ctx,
				layout, notes.getNotes(), from,
				to, 0);

		setListAdapter(adapter);

		notes.close();
	}

/..................
@Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        
        // Set the item as checked to be highlighted when in two-pane layout
        getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        getListView().setItemChecked(position, true);
     
    }

241

Dialog With RadioButton Android Example | dialog-with-radiobutton-android-example



private void dialogModeFC() {
	try {
	final AlertDialog alertDialog =	new AlertDialog.Builder(MainActivity.this)
    .setTitle(R.string.select_dialog)
    //.setItems(
    .setSingleChoiceItems(R.array.select_dialog_items, -1
    		, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

        /* User clicked so do some stuff 
        <item>Happy New Year</item>
        <item>Merry Christmas</item>
        <item>I Love You</item>
        */
            String[] items = getResources().getStringArray(R.array.select_dialog_items);
// list with boolean variables - which is true
//            for (int i = 0; i < _listMode.size(); i++) {
//            	_listMode.set(i, false);
//            }
//            _listMode.set(which, true);
            dialog.dismiss();
//            new AlertDialog.Builder(MainActivity.this)
//                    .setMessage("You selected: " + which + " , " + items[which])
//                    .show();
        }
    })
    .create();
	alertDialog.show();
	} catch (Exception e) {
		e.printStackTrace();
		Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG)
				.show();//("dialogModeFC", e.getMessage().toString());
	}
}// end dialogModeFC	
244

Include xml into another xml Android Example | include-xml-into-another-xml-android-example


How include layout defined in other xml file into another xml file example:
res/layout/my_layout.xml into
main.xml

<include  layout="@layout/my_layout" android:id="@+id/idMyLayout" />
210

No Launcher activity found Android Emulator Error | no-launcher-activity-found-android-emulator-error


Error: No Launcher activity found!
The launch will only sync the application package on the device!
Android emulator not showing the app
Workaround:
Check AndroidManifest.xml for MAIN and LAUNCHER. MyActivity.java is first Activity what will opened if .apk is installed.

<application android:label="@string/app_name" android:icon="@drawable/icon">
    <activity android:name="MyActivity"
              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>
295

Shuffle array int string Java Android | shuffle-array-int-string-java-android



String [] arOfStrings = {"one", "two", "three"};
List<String> mListOfStrings = new ArrayList<String>(Arrays.asList(arOfStrings));
Collections.shuffle(mListOfstrings);
String str = mListOfStrings.get(2);// 2 is index of pozition an element


int [] arOfInt = {1, 2, 3};
List<Integer> mListOfInt = new ArrayList<Integer>(Arrays.asList(arOfInt));
Collections.shuffle(mListOfInt);


Editace: 2011-09-14 20:54:02
Počet článků v kategorii: 397
Url:edittext-text-changed

AD
11 Share
Share
Tweet