Langsung ke konten utama

cara membuat toast sederhana

cara membuat toast sederhana



MainActivity.java

public class MainActivity extends AppCompatActivity {
    Button button;

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        button = (Button) findViewById(R.id.buton);
        button.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View v) {
                /*Context context = getApplicationContext();                CharSequence text = "selamat datang";                int duration = Toast.LENGTH_LONG;
                Toast toast = Toast.makeText(context, text, duration);                toast.show();*/
                LayoutInflater inflater = getLayoutInflater();
                View layout = inflater.inflate(R.layout.logo, (ViewGroup) findViewById(R.id.lokasi));
                Toast toast= new Toast(getApplicationContext());
                toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
                toast.setDuration(Toast.LENGTH_LONG);
                toast.setView(layout);
                toast.show();
            }
        });

    }
}

activityMain.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical"    tools:context="com.example.ipin.toas.MainActivity">

    <Button        android:id="@+id/buton"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="coba" />
</LinearLayout>

dialog.java


public class Dialog extends DialogFragment{
    @Override    public android.app.Dialog getDialog() {
        return super.getDialog();
    }
}

logo.xml



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical" android:layout_width="match_parent"    android:layout_height="match_parent">

    <ImageView        android:layout_width="match_parent"        android:layout_height="match_parent"        android:layout_gravity="center"        android:src="@drawable/lokasi"        android:id="@+id/lokasi"/>

</LinearLayout>


link downloadnya silahkan klik disini

Komentar

Postingan populer dari blog ini

perbedaan SQL dan NoSQL di couchDB

perbedaan SQL dan NoSQL di couchDB   1. INSERT a. SQL (" INSERT INTO 'nama_tabel'(nama field) ") b. couchdb (" $ curl -X PUT 127.0.0.1:5984/nama_DB/”no_id” -d ‘{“nama_field” : “value”}' ") 2. SELECT a. SQL (" SELECT * FROM 'nama_tabel' WHERE 'id'=no_id ") b. couchDB (" $ curl -X GET 127.0.0.1:5984/nama_DB/”no_id” ") 3. UPDATE a. SQL (" UPDATE 'nama_tabel' SET 'nama_field' = 'value' ") b. couchDB (" $ curl -X PUT 127.0.0.1:5984/nama_DB/no_id/ -d '{"_rev" : "no_rev","nama_field" : "value"}'  ") 4. DELETE a. SQL (" DELETE FROM 'nm_tabel' WHERE id=id ") b. couchDB (" $ curl -X DELETE 127.0.0.1:5984/nm_DB/id?rev=no_rev ")  

CONNECT couchDB to PHP

CONNECT couchDB to PHP sorce code silahkan download disini