4

当用户单击按钮时,我正在显示一个对话框。当对话框出现并单击 EditText 以输入一些文本时,您将看不到底部按钮(以及最下方的 EditText)。所以你必须向下单击键盘,然后选择按钮或EditText。我现在搜索了一段时间的答案,但我找不到它。

那么:如何使我的对话框可滚动?显然我的代码没有做到这一点:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:orientation="vertical"
    android:scrollbars="vertical"
    android:scrollbarAlwaysDrawVerticalTrack="true">

<EditText         
   android:id="@+id/addKlantNaam"
   android:textSize="20sp"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:hint="@string/klantNaam" 
   />

<EditText         
   android:id="@+id/addKlantLocatie"
   android:textSize="20sp"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:hint="@string/klantLocatie" 
   />

<TextView
    android:id="@+id/scheidenDoorKomma"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="16sp"
    android:text="@string/scheidenDoorKomma"/>

<EditText         
   android:id="@+id/addFabrieken"
   android:textSize="20sp"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:hint="@string/fabrieken" 
   />

 <EditText        
   android:id="@+id/addMachines"
   android:textSize="20sp"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:hint="@string/machines" 
   />

 <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom" >

    <Button
        android:id="@+id/dialogAnnuleren"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"        
        android:text="@string/annuleren"
        android:textSize="22sp" />

    <Button
        android:id="@+id/dialogToevoegen"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"   
        android:layout_toRightOf="@+id/dialogAnnuleren"     
        android:textSize="22sp"
        android:text="@string/toevoegen"/>
  </RelativeLayout>

</LinearLayout>

这就是我调用对话框的方式:

btnAdd.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View arg0) {

            // custom dialog
            dialog = new Dialog(context);
            dialog.setContentView(R.layout.addklant_layout);
            dialog.setTitle("Klant toevoegen");

            Button BTNannuleren = (Button) dialog.findViewById(R.id.dialogAnnuleren);
            // if button is clicked, close the custom dialog
            BTNannuleren.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });

            Button BTNtoevoegen = (Button) dialog.findViewById(R.id.dialogToevoegen);
            // if button is clicked, close the custom dialog
            BTNtoevoegen.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    StoreKlantInDatabase task = new StoreKlantInDatabase();     
                        task.execute(urlInsertKlant);
                        dialog.dismiss();
                    }
            });      
            dialog.show();
      }
    });

任何人都可以在这里帮助我吗?

4

3 回答 3

1

GeertG ...现在我很情绪化:)尝试我找到的链接...它可能会使用带有多个孩子的滚动视图...我不知道它是否解决了您的问题但是... 如果 ScrollView 仅支持一个直接子级,我应该如何使整个布局可滚动?

或者

如何在android的水平滚动视图中添加多个孩子

这些解决方案应该像创建一个超过 1 个孩子的滚动视图一样工作......它会解决你的问题吗?身份证...

也看看

单击EditText外部后如何在android上隐藏软键盘?

但是关闭并重新打开键盘对我来说似乎有点合理......不要在它上面逗留太久:)

于 2013-10-01T07:13:08.120 回答
1

可以在此处找到您所要求的指南。如你看到的。有多种方法可以实现您的要求。

除此之外,您可以考虑更改键盘上“Enter”按钮的默认操作以选择下一个 EditText,最后在完成后提交表单(在此处阅读):

android:imeOptions="actionDone"
于 2013-10-01T07:15:11.280 回答
0

使用 LinearLayout 高度 match_parent。并尝试它是否有效。

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:orientation="vertical"
    android:scrollbars="vertical"
    android:scrollbarAlwaysDrawVerticalTrack="true">
于 2013-10-01T06:47:11.643 回答