All About Android-Use Dialog Fragments in Honeycomb-ANDROIDKAWE

All About Android-Use Dialog Fragments in Honeycomb-ANDROIDKAWE - Welcome to ANDROID KAWE, Ini adalah sebuah blog directory tentang burung,baik itu suara burung ataupun tips perawatan burung.Blog ini adalah situs perangkum otomatis dari pencarian google yang kali ini berjudul All About Android-Use Dialog Fragments in Honeycomb-ANDROIDKAWE.Ada ribuan artikel yang sudah terekam ke dalam situs ini,silahkan cari sesuai yang kalian kehendaki,untuk artikel selanjutnya tentang judul diatas bisa kalian baca di bawah ini.

Konten : All About Android-Use Dialog Fragments in Honeycomb-ANDROIDKAWE
Judul : All About Android-Use Dialog Fragments in Honeycomb-ANDROIDKAWE

lihat juga


All About Android-Use Dialog Fragments in Honeycomb-ANDROIDKAWE



Using Dialog Fragments in Honeycomb



Honeycomb (Android 3.x) introduced the Fragments to better utilize the UI areas and logic across the multiple activities of the in an application.


The showDialog/dismissDialog methods in Activity are being deprecated to promote the DialogFragments


This post shows a simple DialogFragment example.


The example layout file for the dialog is as follows


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   
android:id="@+id/edit_name"
   
android:layout_width="wrap_content" android:layout_height="wrap_content"
   
android:layout_gravity="center" android:orientation="vertical"  >

   
<TextView
       
android:id="@+id/lbl_your_name" android:text="Your name"
       
android:layout_width="wrap_content" android:layout_height="wrap_content" />
     
   
<EditText
       
android:id="@+id/txt_your_name"
       
android:layout_width="match_parent"  android:layout_height="wrap_content"
       
android:inputType=”text”
       
android:imeOptions="actionDone" />
</LinearLayout>

Create the Dialog Class


The dialog class extends the DialogFragment (to support the DialogFragment on other devices I included the DialogFragment from version 4)
import android.support.v4.app.DialogFragment;
// ...
public class SampleDialog extends DialogFragment {

   
private EditText mEditText;

   
public SampleDialog() {
       
// Empty constructor required for DialogFragment
   
}

   
@Override
   
public View onCreateView(LayoutInflater inflater, ViewGroup container,
           
Bundle savedInstanceState) {
       
View view = inflater.inflate(R.layout.fragment_edit_name, container);
        mEditText
= (EditText) view.findViewById(R.id.txt_your_name);
        getDialog
().setTitle("Hello!CreativeAndroidApps");

       
return view;
   
}
}

Showing the Dialog Box in a Fragment Activity

import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
// ...
public class FragmentDialogDemo extends FragmentActivity implements SampleDialogListener {

   
@Override
   
public void onCreate(Bundle savedInstanceState) {
       
super.onCreate(savedInstanceState);
        setContentView
(R.layout.main);
        showSampleDialog
();
   
}

   
private void showSampleDialog() {
       
FragmentManager fm = getSupportFragmentManager();
        Sample
Dialog sampleDialog = new SampleDialog();
        sampleDialog
.show(fm, "fragment_edit_name");
   
}

   
@Override
   
public void onFinishEditDialog(String inputText) {
       
Toast.makeText(this, "Hi, " + inputText, Toast.LENGTH_SHORT).show();
   
}
}

Please provide your most valuable comments to improve this post.



Demikianlah Artikel All About Android-Use Dialog Fragments in Honeycomb-ANDROIDKAWE

Semoga artikel tentang All About Android-Use Dialog Fragments in Honeycomb-ANDROIDKAWE, mudah-mudahan bisa memberi manfaat untuk anda semua.

Anda sedang membaca artikel All About Android-Use Dialog Fragments in Honeycomb-ANDROIDKAWE dan artikel ini url permalinknya adalah http://androidkawe.blogspot.com/2012/07/all-about-android-use-dialog-fragments.html Semoga artikel ini bisa bermanfaat.Sekali lagi,ini adalah situs auto yang tidak ditulis langsung oleh admin,Kami tidak menjamin akan kebenaran dari artikel yang tertulis.
Back To Top