我已经进入我的AndroidManifest.xml并将标签更改为我的字符串资源,但是当我在手机上启动应用程序时,它只会显示"数字"标签。我确实成功地将它从Miwac更改为数字标签,但现在每个活动都会显示数字标签。
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.miwok">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".NumbersActivity"
android:label="@string/category_numbers"
/>
<activity android:name=".Colors"
android:label="@string/category_colors" />
<activity android:name=".Phrases"
android:label="@string/category_phrases" />
<activity android:name=".FamilyMembers"
android:label="@string/category_family"
>
</activity>
</application>
</manifest>
这是我的mainActivity.java
package com.example.android.miwok;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import static com.example.android.miwok.R.id.phrases;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the content of the activity to use the activity_main.xml layout file
setContentView(R.layout.activity_main);
// Find the View that shows the numbers category
TextView numbers = (TextView) findViewById(R.id.numbers);
// Set a click listener on that View
numbers.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the numbers View is clicked on.
@Override
public void onClick(View view) {
Intent numbersIntent = new Intent(MainActivity.this, NumbersActivity.class);
startActivity(numbersIntent);
}
});
TextView family = (TextView) findViewById(R.id.family);
// Set a click listener on that View
family.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the numbers View is clicked on.
@Override
public void onClick(View view) {
Intent familyIntent = new Intent(MainActivity.this, NumbersActivity.class);
startActivity(familyIntent);
}
});TextView colors = (TextView) findViewById(R.id.colors);
// Set a click listener on that View
colors.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the numbers View is clicked on.
@Override
public void onClick(View view) {
Intent colorsIntent = new Intent(MainActivity.this, NumbersActivity.class);
startActivity(colorsIntent);
}
});TextView phrases = (TextView) findViewById(R.id.phrases);
// Set a click listener on that View
phrases.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the numbers View is clicked on.
@Override
public void onClick(View view) {
Intent phrasesIntent = new Intent(MainActivity.this, NumbersActivity.class);
startActivity(phrasesIntent);
}
});
}
}
答案 0 :(得分:1)
对于每个新意图,您将启动相同的“NumbersActivity”。将其替换为其他活动
Intent numbersIntent = new Intent(MainActivity.this, NumbersActivity.class);
startActivity(numbersIntent);
Intent colorsIntent = new Intent(MainActivity.this, Colors.class);
startActivity(colorsIntent);
Intent phrasesIntent = new Intent(MainActivity.this, Phrases.class);
startActivity(phrasesIntent);