myc_100 2013-07-17 08:46 采纳率: 10%
浏览 2244

在extends Dialog实现Context时如何删除标题?

正如题目所说的我用下面的代码删除标题:

package com.example.dialogbox2;

import android.app.Dialog;  
import android.content.Context;  
import android.os.Bundle;  
import android.view.View;  
import android.widget.Button;  
public class Custom extends Dialog implements android.view.View.OnClickListener{  
    public Custom(Context context) {  
        super(context);  
}  
Button btn;  
    @Override  
    protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.custom);  
        setTitle("This Is Sample Title");
        btn=(Button) findViewById(R.id.dismis_dialog);  
        btn.setOnClickListener(this);  
    }  
    @Override  
    public void onClick(View v) {  
        dismiss();  
    }  
} 

当我在代码中删除setTitle("This Is Sample Title");时,在黑色的背景下还是显示一片小的空间。
Layout 代码:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   android:layout_width="fill_parent"  
   android:layout_height="fill_parent"  
   android:background="#ef8e01"  
   android:orientation="vertical" >  
    <TextView  
     android:layout_width="fill_parent"  
     android:layout_height="wrap_content"  
     android:layout_margin="10dp"  
     android:text="@string/msg"  
     android:textColor="#000"
     android:background="@drawable/ic_launcher" >  
   </TextView>  
   <Button  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:layout_gravity="center_horizontal"  
     android:clickable="true" android:id="@+id/dismis_dialog"  
     android:text="@string/dismis" />  
  </LinearLayout>  
  • 写回答

1条回答

  • JaveZh 2013-07-17 09:00
    关注

    在setContentView前面加一句:

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突