Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有人在Android中使用过EditText框及其下(层下)的ListView?_Android_Listview_Android Edittext - Fatal编程技术网

有没有人在Android中使用过EditText框及其下(层下)的ListView?

有没有人在Android中使用过EditText框及其下(层下)的ListView?,android,listview,android-edittext,Android,Listview,Android Edittext,我试图用不同的(背景)颜色在编辑文本框中标记不同的行,即第1行-蓝色,第2行-黑色等。我通过在背景列表视图的相应文本框中填充颜色来实现这一点。我这样做是因为EditText没有提供一种只能设置一行背景色的方法(任何人都可以提供一种方法,如果你知道的话)。现在,每当用户滚动EditText框时,我也会以相同的数量滚动ListView,以便它们一起移动,感觉EditText框的行设置了相应的背景色 我面临的唯一问题是,当ListView向下/向上滚动时,显示的新行(在ListView中)(显示行下方

我试图用不同的(背景)颜色在编辑文本框中标记不同的行,即第1行-蓝色,第2行-黑色等。我通过在背景列表视图的相应文本框中填充颜色来实现这一点。我这样做是因为EditText没有提供一种只能设置一行背景色的方法(任何人都可以提供一种方法,如果你知道的话)。现在,每当用户滚动EditText框时,我也会以相同的数量滚动ListView,以便它们一起移动,感觉EditText框的行设置了相应的背景色

我面临的唯一问题是,当ListView向下/向上滚动时,显示的新行(在ListView中)(显示行下方的新行)没有任何颜色设置。ListView似乎没有画出显示的新行(文本框)。这是因为ListView位于EditText的背景中(我使用的是相对布局,ListView在下面,EditText在上面)?对于显示的新行,是否有任何方法可以使ListView在滚动时填充正确的颜色

谢谢 编辑:按要求编码: 这是layout.xml中的条目:

<RelativeLayout
    android:id="@+id/container1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1" 
    >
    <ListView android:id="@+id/bgLv1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:dividerHeight="0dp"
        android:divider="@null"
        />
    <EditText android:id="@+id/et1" android:layout_gravity="left" android:layout_height="match_parent" android:layout_width="match_parent" android:text="" android:gravity="center" android:background="@drawable/textbox_border"></EditText>
</RelativeLayout>

这是我为我的桌子画矩形的方式

<?xml version="1.0" encoding="utf-8"?>
<shape
  xmlns:android="http://schemas.android.com/apk/res/android"
android:shape= "rectangle"  >
        <solid android:color="#FFFFFF"/>
        <stroke android:width="1dp"  android:color="#000000"/>
</shape>


请你把一些代码放上去好吗。听起来您可以在layout.xml.Hi标记中使用layoutDown属性,请查找上面更新的代码。让我尝试使用LayoutDown属性——同样,现在您可以看到代码了,您能告诉我如何使用LayoutDown属性以及是否需要使用LayoutDown属性吗。谢谢。看到我下面的答案了。@MarkBasler我想下面的布局是为了在同一平面上设置下面的视图。在我的例子中,ListView是背景层。编辑文本框是ListView上面的层。(我已使编辑文本框背景透明,以便可以看到ListView)。你能提供一些帮助后,这个信息?谢谢。不要用编程的方式使用etLocation.setVisibility(View.visible)将它们设置为可见;btn_方向。设置可见性(视图。消失);好的,那么如何使此形状应用于EditText中的一行?作为背景。谢谢
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    et1 = (EditText)findViewById(R.id.et1);
    et1.setText(inpStr);
    final ListView lv1 = ((ListView)findViewById(R.id.bgLv1));
    final BackgroundListAdapter bla = new BackgroundListAdapter(this,colorLines);
    lv1.setAdapter(bla);
}
<?xml version="1.0" encoding="utf-8"?>
<shape
  xmlns:android="http://schemas.android.com/apk/res/android"
android:shape= "rectangle"  >
        <solid android:color="#FFFFFF"/>
        <stroke android:width="1dp"  android:color="#000000"/>
</shape>