2016-07-25 3 views
0

Android 앱을 만들고 있는데 두 항목 (홈 페이지, 로그 아웃)의 메뉴를 표시하려고합니다. 제 전화의 언어가 아랍어로 바뀌면 메뉴 항목이 전혀 표시되지 않습니다.Android - 메뉴 항목이 아랍어로 표시되지 않습니다.

휴대 전화를 영어로 설정하면 메뉴 항목이 표시되고 모든 기능이 훌륭합니다. 내가 전화의 언어를 아랍어로 바꿀 때까지, 모든 텍스트는 메뉴를 제외한 아랍어로 표시됩니다. 전혀 메뉴가 .. .. !! 제발 어떤 도움을 ?? 여기

는 자바 코드 :

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is present. 
    getMenuInflater().inflate(R.menu.main, menu); 

    return true; 
} 

public boolean onOptionsItemSelected (MenuItem item){ 
    super.onOptionsItemSelected(item); 

    switch(item.getItemId()){ 

    case R.id.home_page: 

     new AlertDialog.Builder(this) 
     .setTitle("Home Page") 
     .setMessage("You Are In The Home Page Now") 
     .setNeutralButton("OK", new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int which){ 
       //Do Nothing 
      } 
     }).show(); 


     break; 

    case R.id.logout: 

     new AlertDialog.Builder(this) 
     .setTitle("Attention!!") 
     .setMessage("Do You Really Want To Logout?") 
     .setNeutralButton("OK", new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int which){ 
       //Empty the Sharedpreferences from the ID value 
       SharedPreferences sp = getSharedPreferences("id_prefs", Activity.MODE_PRIVATE); 
       sp.edit().putString("id", null).commit(); 

       Intent intent = new Intent(Res_Menu.this, MainActivity.class); 
       startActivity(intent); 
      } 
     }).show(); 


     break; 

    } 

    return true; 

} 

그리고 이것은 메뉴 파일 (main.xml에)

<menu xmlns:android="http://schemas.android.com/apk/res/android" > 

<item 
    android:id="@+id/home_page" 
    android:orderInCategory="1" 
    android:showAsAction="ifRoom|withText" 
    android:title="@string/Reseller_Menu"/> 

<item 
    android:id="@+id/logout" 
    android:orderInCategory="2" 
    android:showAsAction="ifRoom|withText" 
    android:title="@string/logout"/> 

</menu> 

입니다 그리고 이것은 아랍 언어에 대한 strings.xml의입니다. 경로 : (고해상도/값-AR/strings.xml의) 여기

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<string name="app_name">مندوب المبيعات</string> 
<string name="action_settings">الضبط</string> 
<string name="hello_world">!مرحبا العالم</string> 
<string name="Welcome_To_Reseller">مرحبا بك في مندوب المبيعات</string> 
<string name="phone">الهاتف</string> 
<string name="Password">كلمة المرور</string> 
<string name="Login">تسجيل دخول</string> 
<string name="Name">الإسم</string> 
<string name="Register">إنشاء</string> 
<string name="Confirm_Password">تأكيد كلمة المرور</string> 
<string name="Register_Account">إنشاء حساب جديد</string> 
<string name="Reseller_Menu">الصفحة الرئيسية</string> 
<string name="Balance_Transfer">تحويل الرصيد</string> 
<string name="Buy_Internet_Package">شراء باقة إنترنت</string> 
<string name="Account_Details">تفاصيل الحساب</string> 
<string name="Enter_Balance_Amount">أدخل المبلغ هنا</string> 
<string name="send">إرسال</string> 
<string name="Enter_Receiver_Phone">أدخل رقم الهاتف المستقبل هنا</string> 
<string name="back">الصفحة السابقة</string> 
<string name="Welcome">مرحبا</string> 
<string name="my_details">تفاصيل حسابي</string> 
<string name="internet_subscription">إشتراك الإنترنت:</string> 
<string name="balance">الرصيد:</string> 
<string name="view">عرض</string> 
<string name="sdg">جنيه سوداني</string> 
<string name="logo">logo</string> 
<string name="enter_phone">أدخل رقم هاتفك هنا</string> 
<string name="enter_password">أدخل كلمة مرورك هنا</string> 
<string name="enter_name">أدخل إسمك هنا</string> 
<string name="enter_confirm_password">أعد كتابة كلمة مرورك هنا</string> 
<string name="amount">المبلغ</string> 
<string name="balance_amount">كمية الرصيد</string> 
<string name="logout">تسجيل خروج</string> 
</resources> 

그리고는 파일과 폴더의 경로를 확인하기 위해 내 패키지 탐색기의 스크린 샷이다. enter image description here

그리고 이것은 영어 활동의 스크린 샷, 당신은 로고 및 메뉴 항목을 볼 수 있습니다 : enter image description here

그리고이 아랍어에있는 활동의 스크린 샷이다, 아무 메뉴도 없다 또는 로고가 나타납니다. enter image description here

+1

요 u set'setTitle'을 설정하고,'setMessage'는 하드 코딩되어 있습니다. 문자열 리소스 – waki

+0

@Waki를 사용하십시오. 좀 더 자세히 설명해 주시겠습니까 ?? 그것은 작동하지 않았다 –

답변

0

menu-ar 리소스 폴더를 추가하고 main.xml을 복사 해보십시오.

+0

이 ... 그것은 오류가 어떤 오류 :( –

+0

함께 제공 – Ben

+0

이 오류 : 여러 개의 마커를 \t Ar은 \t 변수에 해결 될 수없는이 라인에서 ......... \t 변수 –

0

문자열 리소스를 사용하십시오. 두 언어 (EN/AR) strings.xml 예에 추가를 들어

new AlertDialog.Builder(this) 
    .setTitle(R.string.home_title) 
    .setMessage(R.string.you_are_on_home_page) 
    .setNeutralButton(R.string.btn_ok, new DialogInterface.OnClickListener() { 
     public void onClick(DialogInterface dialog, int which){ 
      //Do Nothing 
     } 
    }).show(); 

,
EN :

<string name="you_are_on_home_page">You Are In The Home Page Now</string> 

AR :

<string name="you_are_on_home_page">مندوب المبيعات</string> 

바로 대화 상자에 텍스트를 정당화 정보, 당신이 할 수있는 여기를 읽으십시오 https://stackoverflow.com/a/6131224

+0

귀하의 조치를 취했으나 메뉴 항목 문제로 변경된 사항은 없습니다. –

+0

@RamiRasikh 모든 문자열을 추가 했습니까? 내 대답은 단 한 개의 문자열 예제를 보여주었습니다. – waki

+0

예 모든 문자열을 (strings.xml) 파일에 두 언어로 모두 추가했습니다. 영어로 작동하기 때문에 대화 상자에 하드 코드 된 문자열을 작성한 경우에도 해당 대화 상자는 아랍어로 된 메뉴 항목 문제와 아무 관련이 없습니다. –