کد پیاچپی:
package ir.earthsoft.italyancooking;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.app.Activity;
import android.content.Intent;
public class Menu extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
Button c = (Button) findViewById(R.id.button1);
c.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Menu.this, Feh.class));
}
});
Button cd = (Button) findViewById(R.id.button2);
cd.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Menu.this, Set.class));
}
});
Button cf = (Button) findViewById(R.id.button6);
cf.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Menu.this, About.class));
}
});
if (getIntent().getBooleanExtra("EXIT", false)) {
finish();
}
Button aaaaa = (Button) findViewById(R.id.button7);
aaaaa.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), Menu.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("EXIT", true);
startActivity(intent);
}
});
Button h = (Button) findViewById(R.id.button4);
h.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.instagram.com/erth_soft"));
startActivity(browserIntent);
}
});
Button sh = (Button) findViewById(R.id.button5);
sh.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.earthsoft.ir"));
startActivity(browserIntent);
}
});
}
public boolean onCreateOptionsMenu(android.view.Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu, menu);
return true;
}
}
بفرما اینم کل کدهای اون فایل جاوا
نا گفته نمونه که اکتیویتی اول یا لانچر رو با اسم Splash ساختم
اون چند خط آخر :
کد پیاچپی:
public boolean onCreateOptionsMenu(android.view.Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu, menu);
return true;
که فکر کنم به فایل های xml منو ربط داره هم یکم دستکاری شدن ولی یادم نمیاد چیکار کردم
اسم این اکتیویتی هم Menu است
______________________
واااایییی یه اشتباه بد کردم
ارور فورس کلوس این اکتیویتی اصلا ربطی به فونت نداره چون من توی این نه تایپ فیس تعریف کردم نه چیزیو ارجاع دادم
==========================================================================================================================================================================================================================================================================
حالا بیخیال عنوان
میشه عیب این اکتیویتی رو پیدا کنی برام؟
کد های فایل 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:background="@drawable/back"
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=".Menu" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="@drawable/button_selector"
android:text="فهرست" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button1"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:background="@drawable/button_selector"
android:text="تنظیمات" />
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button2"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="جستوجو"
android:background="@drawable/button_selector" />
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button3"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:background="@drawable/button_selector"
android:text="اینستاگرام سازنده" />
<Button
android:id="@+id/button5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button4"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:background="@drawable/button_selector"
android:text="وبسایت سازنده" />
<Button
android:id="@+id/button6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button7"
android:layout_below="@+id/button5"
android:layout_marginTop="14dp"
android:text="درباره "
android:background="@drawable/button_selector"
/>
<Button
android:id="@+id/button7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button5"
android:layout_alignParentBottom="true"
android:text="خروج"
android:background="@drawable/button_selector"
/>
</RelativeLayout>