Code Android Studio Part 1
TOAST
Context context = getApplicationContext(); CharSequence text = "Hello toast!"; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show();
yang simple :
Toast.makeText(context, text, duration).show();
ALERT DIALOG
LISTVIEW
XML : <ListView
oke guys, mungkin tutorial simplenya dari saya, mohon maaf bila ada kesalahan.
SALAM BLOGGER !!!
AlertDialog dialog = new AlertDialog(context); alertDialog.setCancelable(cancelable); alertDialog.setOnCancelListener(cancelListener);
LISTVIEW
XML : <ListView
android:id="@+id/list_view" android:layout_width="match_parent" android:layout_height="match_parent" />Code:
ListView.setOnItemClickListener(new View)
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
//listview click index
int itemPosition = position;
// listview item click
String itemValue = (String) listView.getItemAtPosition(position);
// perlihatkan alert
Toast.makeText(getApplicationContext(),
"Position :"+posisi item+" ListItem : " +value item , Toast.LENGTH_LONG)
.show();
SPINNER
Spinner spinner = (Spinner) findViewById(R.id.spinner); // buat array adapter menggunakan array string dan ttata etak deafult ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.planets_array, android.R.layout.simple_spinner_item); // Tentukan tata letang yang akan digunakan saat daftar pilihan muncul adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // apply adapter ke spinner spinner.setAdapter(adapter);
oke guys, mungkin tutorial simplenya dari saya, mohon maaf bila ada kesalahan.
SALAM BLOGGER !!!
dasdasdasdasasdasdasdasdad
MEM
Komentar
Posting Komentar