正如我提到的,我只想删除代码中的标题
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");
时,它仍然显示带有黑色背景的litle空间
这是我的布局
<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>
请帮我解决这个问题 谢谢
答案 0 :(得分:2)
使用此选项删除标题栏:
requestWindowFeature(Window.FEATURE_NO_TITLE);