Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android “活动内片段”中的“片段”对话框_Android_Android Dialogfragment - Fatal编程技术网

Android “活动内片段”中的“片段”对话框

Android “活动内片段”中的“片段”对话框,android,android-dialogfragment,Android,Android Dialogfragment,求你了,我需要一些帮助,我对安卓系统很着迷。在这里你有mi代码和logcat下降,我希望你能告诉我的方式 为了更好的理解,我正在寻找的是;在活动“concejos”中,有滑动选项卡,每个选项卡都是一个类似布局的片段,在这些布局中有按钮,这些按钮将打开带有图像、文本和关闭按钮的对话框片段 代码 public class Concejos extends FragmentActivity implements ActionBar.TabListener { AppSectionsPagerAdap

求你了,我需要一些帮助,我对安卓系统很着迷。在这里你有mi代码和logcat下降,我希望你能告诉我的方式

为了更好的理解,我正在寻找的是;在活动“concejos”中,有滑动选项卡,每个选项卡都是一个类似布局的片段,在这些布局中有按钮,这些按钮将打开带有图像、文本和关闭按钮的对话框片段

代码

public class Concejos extends FragmentActivity implements ActionBar.TabListener {

AppSectionsPagerAdapter mAppSectionsPagerAdapter;
ViewPager mViewPager;

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

    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    final ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        actionBar.addTab(
                actionBar.newTab()
                        .setText(mAppSectionsPagerAdapter.getPageTitle(i))
                        .setTabListener(this));
    }
}
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}

@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    mViewPager.setCurrentItem(tab.getPosition());
}

@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}

public static class AppSectionsPagerAdapter extends FragmentPagerAdapter {
    public AppSectionsPagerAdapter(FragmentManager fm) {
        super(fm);
    }
    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return new SectionFragmentCocina();
            case 1:
                return new SectionFragmentComedor();
            case 2:
                return new SectionFragmentCuartoLavado();
            case 3:
                return new SectionFragmentBano();
            default:
                return new SectionFragmentCocina();
         }  
    }

    @Override
    public int getCount() {
        return 4;
    }
    @Override
    public CharSequence getPageTitle(int position) {
        switch (position) {
        case 0:
            return "Cocina";
        case 1:
            return "Comedor";
        case 2:
            return "Cuarto de lavado";
        case 3:
            return "Baño";
        }
        return null;
    }
}


public static class SectionFragmentCocina extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_cocina, container, false);
        // Demonstration of a collection-browsing activity.
        rootView.findViewById(R.id.btnLavavajilla).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Context context = null;
                /*Intent intent = new Intent(getActivity(), SectionFragment1.class);
                startActivity(intent);*/
                final Dialog dialog = new Dialog(context);
                dialog.setContentView(R.layout.fragment_dialog);
                dialog.setTitle("Title...");

                // set the custom dialog components - text, image and button
                TextView text = (TextView) dialog.findViewById(R.id.txtTexto);
                text.setText("Android custom dialog example!");
                ImageView image = (ImageView) dialog.findViewById(R.id.ivImagen);
                image.setImageResource(R.drawable.ic_launcher);

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

                dialog.show();
            }
        });
        return rootView;
     }
}


public static class SectionFragmentComedor extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_comedor, container, false);
        // Demonstration of a collection-browsing activity.
        /*rootView.findViewById(R.id.btnLavavajilla).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), SectionFragment2.class);
                startActivity(intent);
            }
        });*/
        return rootView;
     }
}

public static class SectionFragmentCuartoLavado extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_cuarto_lavado, container, false);
        // Demonstration of a collection-browsing activity.
        /*rootView.findViewById(R.id.btnLavavajilla).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), SectionFragment3.class);
                startActivity(intent);
            }
        });*/
        return rootView;
     }
}

public static class SectionFragmentBano extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_bano, container, false);
        // Demonstration of a collection-browsing activity.
        /*rootView.findViewById(R.id.btnLavavajilla).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), SectionFragment4.class);
                startActivity(intent);
            }
        });*/
        return rootView;
     }
}
公共类Concejos扩展了FragmentActivity实现ActionBar.TabListener{
应用分区SPAGERAAdapter映射分区SPAGERAAdapter;
ViewPager mViewPager;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_concejos);
mAppSectionsPagerAdapter=新的AppSectionsPagerAdapter(getSupportFragmentManager());
最终ActionBar ActionBar=getActionBar();
actionBar.setHomeButtonEnabled(假);
actionBar.setNavigationMode(actionBar.NAVIGATION\u MODE\u选项卡);
mViewPager=(ViewPager)findViewById(R.id.pager);
mViewPager.setAdapter(mAppSectionsPagerAdapter);
mViewPager.setOnPageChangeListener(新的ViewPager.SimpleOnPageChangeListener(){
@凌驾
已选择页面上的公共无效(内部位置){
//在不同的应用程序分区之间滑动时,请选择相应的选项卡。
//如果有对
//标签。
actionBar.setSelectedNavigationItem(位置);
}
});
//对于应用程序中的每个部分,在操作栏中添加一个选项卡。
对于(int i=0;i06-04 10:05:59.111: D/dalvikvm(560): GC_FOR_ALLOC freed 99K, 3% free 6972K/7171K, paused 133ms
06-04 10:05:59.151: I/dalvikvm-heap(560): Grow heap (frag case) to 8.370MB for 1536016-byte allocation
06-04 10:05:59.331: D/dalvikvm(560): GC_CONCURRENT freed 1K, 3% free 8471K/8711K, paused 9ms+35ms
06-04 10:06:00.581: D/gralloc_goldfish(560): Emulator without GPU emulation detected.
06-04 10:06:00.781: W/TextLayoutCache(560): computeValuesWithHarfbuzz -- need to force to single run
06-04 10:07:37.460: D/dalvikvm(560): GC_CONCURRENT freed 20K, 2% free 8923K/9095K, paused 10ms+53ms
06-04 10:07:42.911: D/dalvikvm(560): GC_FOR_ALLOC freed 99K, 3% free 8965K/9223K, paused 72ms
06-04 10:07:42.962: I/dalvikvm-heap(560): Grow heap (frag case) to 10.071MB for 1280016-byte allocation
06-04 10:07:43.261: D/dalvikvm(560): GC_CONCURRENT freed 9K, 3% free 10205K/10503K, paused 45ms+8ms
06-04 10:07:43.912: D/dalvikvm(560): GC_FOR_ALLOC freed 4K, 3% free 10377K/10631K, paused 93ms
06-04 10:07:43.941: I/dalvikvm-heap(560): Grow heap (frag case) to 11.451MB for 1280016-byte allocation
06-04 10:07:44.183: D/dalvikvm(560): GC_CONCURRENT freed <1K, 3% free 11626K/11911K, paused 8ms+9ms
06-04 10:07:45.182: W/TextLayoutCache(560): computeValuesWithHarfbuzz -- need to force to single run
06-04 10:07:48.961: D/AndroidRuntime(560): Shutting down VM
06-04 10:07:48.961: W/dalvikvm(560): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
06-04 10:07:49.001: E/AndroidRuntime(560): FATAL EXCEPTION: main
06-04 10:07:49.001: E/AndroidRuntime(560): java.lang.NullPointerException
06-04 10:07:49.001: E/AndroidRuntime(560):  at android.app.Dialog.<init>(Dialog.java:149)
06-04 10:07:49.001: E/AndroidRuntime(560):  at android.app.Dialog.<init>(Dialog.java:127)
06-04 10:07:49.001: E/AndroidRuntime(560):  at com.astrixapp.Concejos$SectionFragmentCocina$1.onClick(Concejos.java:123)
06-04 10:07:49.001: E/AndroidRuntime(560):  at android.view.View.performClick(View.java:3480)
06-04 10:07:49.001: E/AndroidRuntime(560):  at android.view.View$PerformClick.run(View.java:13983)
06-04 10:07:49.001: E/AndroidRuntime(560):  at android.os.Handler.handleCallback(Handler.java:605)
06-04 10:07:49.001: E/AndroidRuntime(560):  at android.os.Handler.dispatchMessage(Handler.java:92)
06-04 10:07:49.001: E/AndroidRuntime(560):  at android.os.Looper.loop(Looper.java:137)
06-04 10:07:49.001: E/AndroidRuntime(560):  at android.app.ActivityThread.main(ActivityThread.java:4340)
06-04 10:07:49.001: E/AndroidRuntime(560):  at java.lang.reflect.Method.invokeNative(Native Method)
06-04 10:07:49.001: E/AndroidRuntime(560):  at java.lang.reflect.Method.invoke(Method.java:511)
06-04 10:07:49.001: E/AndroidRuntime(560):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-04 10:07:49.001: E/AndroidRuntime(560):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-04 10:07:49.001: E/AndroidRuntime(560):  at dalvik.system.NativeStart.main(Native Method)
06-04 10:07:53.230: I/Process(560): Sending signal. PID: 560 SIG: 9
Context context = null;
Context context = SectionFragmentCocina.this.getActivity();