【问题标题】:Bad xml block 3 linearlayout and 2 calender坏 xml 块 3 线性布局和 2 日历
【发布时间】:2013-03-21 06:49:06
【问题描述】:

嗨,我正在尝试创建一个 xml 文件,其中包括 1-标签“任务”和一个文本视图,供用户输入 2-标签“价格”和它下面的文本视图供用户输入 3-label 'category' 和一个有 6 个选项的组合框 4- 标签“结束日期”和旁边的日历 5- 标签“提醒日期”和旁边的日历 最后是一个保存按钮 问题是我在eclipse上找不到组合框,第二个日历和按钮没有出现 这是代码

xml文件

   <?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
<!-- Name Label -->
    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/tsk"
        android:paddingLeft="10dip"
        android:paddingRight="10dip"
        android:paddingTop="10dip"
        android:textSize="17dip"/>

     <!-- Input Name -->
    <EditText 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dip"
        android:layout_marginBottom="15dip"
        android:singleLine="true"/> 

      <!-- Price Label -->
    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/price"
        android:paddingLeft="10dip"
        android:paddingRight="10dip"
        android:paddingTop="10dip"
        android:textSize="17dip"/> 

    <!-- Input Price -->
    <EditText 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dip"
        android:layout_marginBottom="15dip"
        android:singleLine="true"
        android:inputType="numberDecimal"/> 

    <!-- category Label -->
    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/cat"
        android:paddingLeft="10dip"
        android:paddingRight="10dip"
        android:paddingTop="10dip"
        android:textSize="17dip"/> 

    <!-- Input category -->

    <EditText
        android:layout_width="fill_parent"
        android:layout_height="32dp"
        android:layout_margin="5dip"
        android:layout_marginBottom="15dip"
        android:gravity="top"
        android:lines="4" />

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:paddingTop="4dip"
    android:paddingBottom="6dip"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView
        android:layout_width="90dip"
        android:layout_height="wrap_content"
        android:layout_weight="0.00"
        android:text="@string/de" />
    <Calender
        android:layout_width="wrap_content"
        android:layout_height="36dp" />
      </LinearLayout>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:paddingTop="4dip"
    android:paddingBottom="6dip"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView
        android:layout_width="90dip"
        android:layout_height="wrap_content"
        android:layout_weight="0.00"
        android:text="@string/de" />
    <Calender
        android:layout_width="wrap_content"
        android:layout_height="66dp" />
      </LinearLayout>

<!-- Button Create task -->
    <Button 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/save"/> 

</LinearLayout>

还有很多错误

[2013-03-30 21:46:01 - checklist] W/ResourceType(12304): Bad XML block: header size 301 or total size 0 is larger than data size 0
[2013-03-30 21:46:01 - checklist] C:\Users\Najd\workspace\checklist\res\values\strings.xml:4: error: Found tag id where item is expected
[2013-03-30 21:46:01 - checklist] C:\Users\Najd\workspace\checklist\res\layout\add_task.xml:7: error: Error: No resource found that matches the given name (at 'text' with value '@string/tsk').
[2013-03-30 21:46:01 - checklist] C:\Users\Najd\workspace\checklist\res\layout\add_task.xml:24: error: Error: No resource found that matches the given name (at 'text' with value '@string/price').
[2013-03-30 21:46:01 - checklist] C:\Users\Najd\workspace\checklist\res\layout\add_task.xml:42: error: Error: No resource found that matches the given name (at 'text' with value '@string/cat').
[2013-03-30 21:46:01 - checklist] C:\Users\Najd\workspace\checklist\res\layout\add_task.xml:67: error: Error: No resource found that matches the given name (at 'text' with value '@string/de').
[2013-03-30 21:46:01 - checklist] C:\Users\Najd\workspace\checklist\res\layout\add_task.xml:80: error: Error: No resource found that matches the given name (at 'text' with value '@string/save').
[2013-03-30 21:46:01 - checklist] C:\Users\Najd\workspace\checklist\res\menu\activity_main_task.xml:3: error: Error: No resource found that matches the given name (at 'title' with value '@string/menu_settings').

【问题讨论】:

    标签: java android xml android-layout android-widget


    【解决方案1】:

    您指的是@string/save@string/de 等字符串,但它们不存在。将它们添加到您的 strings.xml 文件中:

    <string name="save">Save</string>
    

    【讨论】:

    • 将您的 strings.xml 文件添加到您的问题中
    • 好像没有问题。尝试保存所有文件并清理项目:project > clean.
    • 第二个日历和按钮没有出现怎么办?你能找出问题所在
    • @Najd 因为没有空间,所以你的布局保持在ScrollView中
    • 您必须将两个 LinearLayouts(内部带有日历)的 layout_heigh 设为 wrap_content 而不是 fill_parent
    【解决方案2】:

    我想,你打错了:string.xml 应该重命名为 strings.xml

    【讨论】:

    • 这不应该发挥作用,因为资源文件名不必像那样调用。这只是一个约定。
    【解决方案3】:

    我使用了一种线性布局,现在就足够了

    <?xml version="1.0" encoding="utf-8"?> 
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >
    
         <!-- Name Label -->
    
    
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="10dip"
            android:paddingRight="10dip"
            android:paddingTop="10dip"
            android:text="@string/tsk"
            android:textSize="17dip"
            android:gravity="right" />
    
        <!-- Input Name -->
    
        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dip"
            android:layout_marginBottom="15dip"
            android:singleLine="true" />
    
        <!-- Price Label -->
    
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="10dip"
            android:paddingRight="10dip"
            android:paddingTop="10dip"
            android:text="@string/price"
            android:textSize="17dip" 
            android:gravity="right"/>
    
        <!-- Input Price -->
    
        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dip"
            android:layout_marginBottom="15dip"
            android:inputType="numberDecimal"
            android:singleLine="true" />
    
        <!-- category Label -->
    
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="10dip"
            android:paddingRight="10dip"
            android:paddingTop="10dip"
            android:text="@string/cat"
            android:textSize="17dip"
            android:gravity="right" />
    
        <!-- Input category -->
    
        <EditText
            android:layout_width="fill_parent"
            android:layout_height="32dp"
            android:layout_margin="5dip"
            android:layout_marginBottom="15dip"
            android:gravity="top"
            android:lines="4" />
    
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="right"
            android:text="@string/de" />
    
        <CalendarView
            android:id="@+id/calendarView1"
            android:layout_width="wrap_content"
            android:layout_height="59dp"
            android:gravity="right" />
    
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.20"
            android:gravity="right"
            android:text="@string/dr" />
    
        <CalendarView
            android:id="@+id/calendarView2"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:layout_weight="0.39"
            android:gravity="right" />
    
        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/save" />
    
    </LinearLayout>
    

    【讨论】:

      猜你喜欢
      • 2019-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多