KnightBubble / android-notes

android-notes
0 stars 1 forks source link

DialogFragment-1 #5

Open KnightBubble opened 9 years ago

KnightBubble commented 9 years ago

mainActivity

package com.example.androidstudytest;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @SuppressLint("NewApi")
    public void clickYourName(View view) {
        myDialogFragment mdf = new myDialogFragment();
        mdf.show(getFragmentManager(), "justTest");
    }

}
KnightBubble commented 9 years ago

自定义dialog fragment

package com.example.androidstudytest;

import android.annotation.SuppressLint;
import android.app.DialogFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

@SuppressLint("NewApi")
public class myDialogFragment extends DialogFragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = null;
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);  
        view = inflater.inflate(R.layout.edit_fragment, container);
        return view;
    }
}
KnightBubble commented 9 years ago
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);  

去掉默认对话框有个讨厌的标题