Android Activity Toast Mesaj (Bildirim Mesajı)

ActivityMain Dosyası

package tr.com.emrahkahraman.toast;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class ActivityMain extends ActionBarActivity {

Button btnToastMessage;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnToastMessage = (Button) findViewById(R.id.btnToastMessage);
btnToastMessage.setOnClickListener(clickListener);

}

private OnClickListener clickListener = new OnClickListener()
{
public void onClick(View v)
{
switch (v.getId())
{
case R.id.btnToastMessage:
Toast.makeText(ActivityMain.this,
"Toast Mesaj butonuna tıklandı.", Toast.LENGTH_LONG).show();
break;
}
}
};

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item)
{
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}

activity_main.xml Dosyası
[code lang=”xml”]
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="tr.com.emrahkahraman.toast.ActivityMain" >

<Button
android:id="@+id/btnToastMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btnToastMessage" />

</RelativeLayout>

Ekran Görüntüsü
Screenshot_2015-05-01-21-26-26

Proje Kodunu İndirmek İçin Tıklayınız

“Android Activity Toast Mesaj (Bildirim Mesajı)” üzerine 1 yorum.

Bir cevap yazın