小编Dnw*_*hma的帖子

如何在java中使用for循环清除文本字段

我在Java中创建了如下文本字段.当我单击"清除"按钮时,我想立即清除所有这些文本字段.

private javax.swing.JTextField num1;
private javax.swing.JTextField num2;
private javax.swing.JTextField num3;
private javax.swing.JTextField num4;
private javax.swing.JTextField num5;
private javax.swing.JTextField num6;
private javax.swing.JTextField num7;
Run Code Online (Sandbox Code Playgroud)

现在我想知道如何使用for循环来清除所有文本字段,如:

for(int i=1;1<7;i++){
   num[i].settext(null);
}
Run Code Online (Sandbox Code Playgroud)

java swing clear jtextfield

2
推荐指数
2
解决办法
1万
查看次数

在android中为RelativeLayout添加背景图片

我尝试使用添加背景图片到Android应用程序android:background="@drawable/imageURL".我将图像添加到drawable-hdpi文件夹,但是我收到了错误.我正在尝试将图像添加到RelativeLayout.我也试过用,LinearLayout但它也没用.

那么如何RelativeLayout在Android中向我的应用添加背景图像?

错误是什么?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/abc.png"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/hello_world" />

    </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android background background-image android-layout

1
推荐指数
1
解决办法
1204
查看次数