我是android新手,面临一些xml问题,我在xml文件中添加了一些基本代码,并将 View 设置为这个xml文件(edit_task.xml)
,如下所示
public class EditTask extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_task);
}
edit_task.xml
中的代码是这样的
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:text="@string/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<EditText
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/body"
/>
<EditText
android:id="@+id/body"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minLines="5"
android:scrollbars="vertical"
android:gravity="top" />
<TextView
android:text="@string/date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/reminder_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Reminder_Time"
/>
<TextView
android:text="@string/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/remindertime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/remindertime"
/>
<Button
android:id="@+id/confirm"
android:text="@string/confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</ScrollView>
现在,当我编译它时,它显示hello world而不是这个xml,Hello world id添加到我的strings.xml中,但它没有在上面提到的xml中指向
,所以它有什么问题,请指导我这件事..
这就是我将其添加到Manifest.xml
<activity
android:name="com.example.mytastreminder.EditTask"
android:label="@string/app_name" >
</activity>
最佳答案
在您的 list 中,更改以下内容:
<activity
android:name=".HelloAndroidActivity"
android:label="@string/title_activity_hello_android" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
作者:
<activity
android:name=".EditTask "
android:label="@string/app_name" >
<intent-filter>
**<action android:name="android.intent.action.MAIN" />**
**<category android:name="android.intent.category.LAUNCHER"/>**
</intent-filter>
</activity>
您需要设置 Activity
的操作/类别。在上面的示例中,您说 EditTask 是应用程序的Main
Activity,也是您启动
应用程序时显示的 Activity。
只有一项 Activity 可以具有该特定操作/类别。他们还可以执行其他操作,例如:VIEW
、EDIT
、SEARCH
等。但是只有一个具有上述操作.
关于java - 安卓 :xml file not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20690047/