Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中硬编码值的国际化_Android_Android Layout_Android Intent_Android Activity_Android Fragments - Fatal编程技术网

android中硬编码值的国际化

android中硬编码值的国际化,android,android-layout,android-intent,android-activity,android-fragments,Android,Android Layout,Android Intent,Android Activity,Android Fragments,hiii 我已经创建了一个应用程序,我想在其中使用国际化。但问题是我使用了一个由硬编码值组成的列表…例如,该列表以列表视图的形式由药物、约会等组成 我想在下面这行代码中应用这个国际化 String[] person = new String[] { "Encounter", "Medications","Weight","BloodPressure", "BloodSugar","Lab and

hiii

我已经创建了一个应用程序,我想在其中使用国际化。但问题是我使用了一个由硬编码值组成的列表…例如,该列表以列表视图的形式由药物、约会等组成

我想在下面这行代码中应用这个国际化

 String[] person = new String[] { "Encounter", "Medications","Weight","BloodPressure",
                                                  "BloodSugar","Lab and Test Results","Office Visit","Office Info","Data Analysis","Appointment","Allergy","Problem"};  
如何对这些硬编码值使用国际化..请建议

Tab1.java

package com.example.app;

import java.util.ArrayList;
import java.util.Arrays;


import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.app.Activity;
import android.content.Intent;


public class Tab1 extends Activity 
{

    private ListView infoListView ;  
    private ArrayAdapter<String> listAdapter ;
    /** Called when the activity is first created. */

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

       // Find the ListView resource.   
            infoListView = (ListView) findViewById( R.id.infoListView );  

            // Create and populate a List of planet names.  
            String[] person = new String[] { "Encounter", "Medications","Weight","BloodPressure",
                                              "BloodSugar","Lab and Test Results","Office Visit","Office Info","Data Analysis","Appointment","Allergy","Problem"};    
            ArrayList<String> personList = new ArrayList<String>();  
            personList.addAll( Arrays.asList(person) );  

            // Create ArrayAdapter using the planet list.  
            listAdapter = new ArrayAdapter<String>(this, R.layout.inforow, personList);  


            // Set the ArrayAdapter as the ListView's adapter.  
            infoListView.setAdapter( listAdapter );  
           /* infoListView.setOnItemClickListener(new OnItemClickListener() 
            {

                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1,
                        int arg2, long arg3) {

                    Intent i3=new Intent(Info.this,Call.class);
                    startActivity(i3);

                }

            });*/

            infoListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
            {

                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1,
                        int position, long arg3) 
                {
                     switch (position) 
                     {
                        /*case :
                            Intent i1= new Intent (Tab1.this ,Person.class);
                            startActivity(i1);
                            break;*/
                        case 0 :
                        Intent i2 = new Intent (Tab1.this ,History.class);
                        startActivity(i2);
                        break;

                        case 1 :
                            Intent i3 = new Intent (Tab1.this , Medications.class);
                            startActivity(i3);
                            break;

                        case 2:
                            Intent i4 = new Intent (Tab1.this , Weight.class);
                            startActivity(i4);
                            break;
                        case 3:
                            Intent i5 = new Intent (Tab1.this , BloodPressure.class);
                            startActivity(i5);
                            break;
                        case 4:
                            Intent i6 = new Intent (Tab1.this , BloodSugar.class);
                            startActivity(i6);
                            break;
                        case 5:
                            Intent i7 = new Intent (Tab1.this , LabAndTestResults.class);
                            startActivity(i7);
                            break;
                        case 6:
                            Intent i8 = new Intent (Tab1.this , OfficeVisit.class);
                            startActivity(i8);
                            break;
                        case 7:
                            Intent i9 = new Intent (Tab1.this , Office_info_button.class);
                            startActivity(i9);
                            break;

                        case 8:
                            Intent i10 = new Intent (Tab1.this ,SimpleListActivity.class);
                            startActivity(i10);
                            break;
                        case 9:
                            Intent i11 = new Intent (Tab1.this ,Appointment1.class);
                            startActivity(i11);
                            break;
                        case 10:
                            Intent i12 = new Intent (Tab1.this ,Allergy.class);
                            startActivity(i12);
                            break;

                        case 11:
                            Intent i13 = new Intent (Tab1.this ,ProblemButton.class);
                            startActivity(i13);
                            break;
                     }
                }

            });
          }  
        }
Tab1.xml

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

    <ListView android:layout_width="fill_parent"   
      android:layout_height="fill_parent"   
      android:id="@+id/infoListView">  
    </ListView> 
    </LinearLayout>

请帮助…

至于strings.xml,请将一些arrays.xml文件放在本地化的values xx文件夹中。顺便说一句,由于API级别为8,填充父项现在已被弃用并替换为匹配父项。您能提供一些示例代码吗请参阅本教程:谢谢..它成功了