Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.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 - Fatal编程技术网

Android 画一个碎片

Android 画一个碎片,android,Android,我想在片段中添加我自己的图形。 例如,是否可以在片段中添加一个圆? 我有以下代码: public static class DummySectionFragment extends Fragment { /** * The fragment argument representing the section number for this * fragment. */ public static final String ARG_SECTION_N

我想在片段中添加我自己的图形。 例如,是否可以在片段中添加一个圆? 我有以下代码:

public static class DummySectionFragment extends Fragment  {
    /**
     * The fragment argument representing the section number for this
     * fragment.
     */
    public static final String ARG_SECTION_NUMBER = "section_number";
    public static final String ARG_OBJECT = "object";
    public static final String ARG_DATA = "data";


    public DummySectionFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        Bundle args = getArguments();
        int position = args.getInt(ARG_OBJECT);
        String data=args.getString(ARG_DATA);
        int tabLayout = 0;
        switch (position) {
        case 0:
        tabLayout = R.layout.fragment_company_products;
        break;
        case 1:
        tabLayout = R.layout.fragment_main_dummy;
        break;
        case 2:
        tabLayout = R.layout.fragment_main_dummy;
        break;
        case 3:
            tabLayout = R.layout.fragment_main_dummy;
        break;
        }

        View rootView = inflater.inflate(tabLayout, container, false);

        TextView dummyTextView = (TextView) rootView.findViewById(R.id.section_label);

        //dummyTextView.setText(args.getInt(ARG_OBJECT)+"\n"+data+"asd");
        return rootView;
    }


}
我问这个问题是因为我想在每个片段上更改我的图形,在其中一些片段上,我应该添加一些2d图形,如圆形、圆弧或矩形。 这可能吗?
提前感谢您

您可以将
视图
子类添加到
片段
的布局中,并在
onDraw

中进行自定义绘图。您知道如何选择该自定义视图吗?片段会使常规布局膨胀。只需将您的自定义视图放在碎片膨胀的布局中。。。