我想本地化(values-ru)字符串值:textview和app_name.应用程序仅本地化textview("Приветмир"),但app_name仍然相同("本地化").app_name本地化有什么问题?
Manifest中的应用程序标签名称和活动标签名称是指相应的字符串值.
表现:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.local.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
字符串res/values-ru:
<resources>
<string name="hello_world">?????? ???</string>
<string name="app_name">???????????</string>
</resources>
Run Code Online (Sandbox Code Playgroud)
Java的:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String languageToLoad = "ru";
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
setContentView(R.layout.activity_main);
}
Run Code Online (Sandbox Code Playgroud) 我设置了启动活动,在几秒钟后启动另一个活动.无论如何,我想再添加一个功能:不仅在5秒后开始第二个活动,而是在点击我的初始视图后开始.我一设置下一个:
View v = (View)findViewById(R.layout.splash);
v.setOnClickListener(this);
setContentView(v);
Run Code Online (Sandbox Code Playgroud)
代替
setContentView(R.layout.splash);
Run Code Online (Sandbox Code Playgroud)
我的项目没有运行.问题出在哪儿?
这是我的代码:
public class SlashC extends Activity implements Runnable, OnClickListener {
Thread timer;
MediaPlayer hTree;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View v = (View)findViewById(R.layout.splash); // problems start here
v.setOnClickListener(this);
setContentView(v);
hTree = MediaPlayer.create(this, R.raw.happy_tree);
hTree.start();
timer = new Thread(this);
timer.start();
}
public void onClick(View v) {
// TODO Auto-generated method stub
Intent class2 = new Intent("com.roger.calc.MainActivity");
startActivity(class2);
}
public void run() {
// TODO Auto-generated method stub
try { …Run Code Online (Sandbox Code Playgroud)