2011-12-08 73 views
0

这是我自定义的“更改密码”对话框按钮没有得到显示honeyconb

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

    <TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="5dp" android:stretchColumns="1"> 

     <TableRow android:layout_width="fill_parent"> 
      <TextView android:text="Old Password " android:id="@+id/textViewOldPwd" 
       android:isScrollContainer="true" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" android:textSize="10dp" 
       android:gravity="right" android:layout_marginRight="5dp" /> 
      <EditText android:text="" android:id="@+id/editTextOPwd" android:singleLine="true" 
       android:layout_width="fill_parent" android:layout_height="wrap_content" 
       android:password="true" /> 
     </TableRow> 

     <TableRow android:layout_width="fill_parent"> 
      <TextView android:text="New Password " android:id="@+id/textView0" 
       android:isScrollContainer="true" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" android:textSize="10dp" 
       android:gravity="right" android:layout_marginRight="5dp" /> 
      <EditText android:text="" android:id="@+id/editTextNPwd" android:singleLine="true" 
       android:layout_width="fill_parent" android:layout_height="wrap_content" 
       android:password="true" /> 
     </TableRow> 

     <TableRow android:layout_width="fill_parent"> 
      <TextView android:text="Confirmation " android:id="@+id/textView1" 
       android:isScrollContainer="true" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" android:textSize="10dp" 
       android:gravity="right" android:layout_marginRight="5dp" /> 
      <EditText android:text="" android:id="@+id/editTextCPwd" android:singleLine="true" 
       android:layout_width="fill_parent" android:layout_height="wrap_content" 
       android:password="true" /> 
     </TableRow> 

    </TableLayout> 

    <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" > 
      <Button android:text="Change Password" android:layout_width="fill_parent" android:id="@+id/btnChangePwd" 
       android:layout_height="wrap_content" android:layout_weight=".50" /> 
      <Button android:text="Cancel" android:layout_width="fill_parent" android:id="@+id/btnCancelPwd" 
       android:layout_height="wrap_content" android:layout_weight=".50" /> 
    </LinearLayout> 

</LinearLayout> 

最后两个按钮btnChangePwd和btnCancelPwd越来越正确显示在野火(安卓2.2),但不是在galay标签(Android 3.1 )。它只是来作为空的空间。其它代码

部分是:

final Dialog dialog = new Dialog(this, R.style.FullHeightDialog); 
final View passwordDialog = LayoutInflater.from(this).inflate(R.layout.newpassword, null); 
dialog.setContentView(passwordDialog); 


<resources> 
    <style name="FullHeightDialog" parent="android:style/Theme.Dialog"> 
     <item name="android:windowNoTitle">true</item> 
    </style> 
</resources> 

回答

1

实际上,我认为这是在2.2中的错误。 Wildfire,因为指定了xml的方式,这些按钮不应该显示出来。问题线是:

<TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="5dp" android:stretchColumns="1"> 

查看关于layout_height的部分?这意味着这将填充父项,接下来的按钮将被推出屏幕。在模拟器中,无论使用什么版本,情况都是如此。将其更改为wrap_content使按钮显示。

+0

感谢您指出。我的错。但令人惊讶的高度=“fill_parent”完美适用于对话,但不是活动。 (这个改变并没有解决我的问题!) –

+0

哇,这很奇怪,它在模拟器上为我修复了3.2的对话框。如果我离开fill_parent,则不会出现按钮,如果我更改为wrap_content,它们就会出现。我想我将不得不在我的标签上尝试它,看看它为什么不解决它。 – Kaediil