Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/343.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
Java 如何在ListView的每一行中插入微调器_Java_Android_Listview - Fatal编程技术网

Java 如何在ListView的每一行中插入微调器

Java 如何在ListView的每一行中插入微调器,java,android,listview,Java,Android,Listview,如何将微调器插入片段的onCreateView? 如果我在下面写一个微调器: ViewGroup rootView = (ViewGroup)inflater.inflate(R.layout.fragment_list2, container, false); 这将导致微调器的布局不正确,但它是PlanetAdapter中对象的正确布局 通过这种方式,我在listview下有了微调器,而我希望微调器进入listview的行视图 微调器进入另一个名为:单个列表视图项目的布局 下面您可以看到我

如何将
微调器插入
片段的
onCreateView

如果我在下面写一个
微调器

 ViewGroup rootView = (ViewGroup)inflater.inflate(R.layout.fragment_list2, container, false);
这将导致
微调器的布局不正确
,但它是
PlanetAdapter
中对象的正确布局
通过这种方式,我在listview下有了微调器,而我希望微调器进入listview的行视图
微调器
进入另一个名为:
单个列表视图项目的布局

下面您可以看到我迄今为止所做的尝试:

片段:

public class MyListFragment extends Fragment implements
        android.widget.CompoundButton.OnCheckedChangeListener,AdapterView.OnItemSelectedListener {

    ListView lv;
    ArrayList<Planet> planetList;
    static PlanetAdapter plAdapter;
    private TextView txtName;
    private TextView txtEmail;
    private Button btnLogout;
    private Spinner spinner1;
    private Spinner spinner2;
    Spinner spinner;

    private SQLiteHandler db;
    private SessionManager session;
    BirraAdapter biAdapter;
    PlanetAdapter.PlanetHolder holder;
    private static Context context = null;
    private static FragmentActivity mInstance;

    Integer[] imageId = {
            R.mipmap.androtuto,
            R.mipmap.ic_launcher,
            R.mipmap.ic_launcher,
            R.mipmap.ic_launcher,
            R.mipmap.ok,
            /*R.drawable.image6,
            R.drawable.image7*/

    };

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the custom_spinner_items for this fragment
        //super.onDestroy();

        SharedPreferences settings = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = settings.edit();
        editor.clear();
        editor.commit();
        ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_list2, container, false);

        spinner = (Spinner) rootView.findViewById(R.id.simpleSpinner);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this.getContext(),
                R.array.country_arrays, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
        spinner.setOnItemSelectedListener(this);
        context = getActivity();
        mInstance = getActivity();
        txtName = (TextView) rootView.findViewById(R.id.name);
        txtEmail = (TextView) rootView.findViewById(R.id.numero_telefonico);
        btnLogout = (Button) rootView.findViewById(R.id.btnLogout);

        // SqLite database handler
        db = new SQLiteHandler(context.getApplicationContext());


        // session manager
        session = new SessionManager(context.getApplicationContext());
/*

        if (!session.isLoggedIn()) {
            logoutUser();
        }
*/

        // Fetching user details from SQLite
        HashMap<String, String> user = db.getUserDetails();

        String name = user.get("name");
        //String email = user.get("email");
//      String email = user.get("email");
        String email = user.get("numero_telefonico");


        // Displaying the user details on the screen
        System.out.println(name + email);

        txtName.setText(name);
        txtEmail.setText(email);
    /*  Button mButton = (Button) rootView.findViewById(R.id.button);
        mButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                showResult(v);


            }
        });*/
        //return inflater.inflate(R.custom_spinner_items.fragment_list2, container, false);
        btnLogout.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                logoutUser();
            }
        });
    /*  Spinner spinner = (Spinner) getView().findViewById(R.id.simpleSpinner);
        ArrayAdapter<String> adapter_state = new ArrayAdapter<String>(this,
                android.R.layout.simple_spinner_item, state);
        adapter_state
                .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter_state);
        spinner.setOnItemSelectedListener(this);*/


        return rootView;
    }
公共类MyListFragment扩展了片段实现
android.widget.CompoundButton.OnCheckedChangeListener,AdapterView.OnItemSelectedListener{
ListView lv;
ArrayList planetList;
静态飞机捕捉器;
私有文本视图txtName;
私有文本视图txtEmail;
私用按钮;
私人纺纱机1;
私人纺纱机纺纱机2;
纺纱机;
私有SQLiteHandler数据库;
私人会话管理器会话;
双适配器;
刨刀座;
私有静态上下文=null;
私有静态碎片;
整数[]图像ID={
R.mipmap.androtuto,
R.mipmap.ic_发射器,
R.mipmap.ic_发射器,
R.mipmap.ic_发射器,
R.mipmap.ok,
/*R.drawable.image6,
R.drawable.image7*/
};
@凌驾
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
//为该碎片的自定义\u微调器\u项目充气
//super.ondestory();
SharedReferences设置=getContext().GetSharedReferences(“状态”,Context.MODE\u PRIVATE);
SharedReferences.Editor=settings.edit();
编辑器.clear();
commit();
ViewGroup rootView=(ViewGroup)充气器。充气(R.layout.fragment_list2,容器,false);
微调器=(微调器)rootView.findViewById(R.id.SimpleSpiner);
ArrayAdapter=ArrayAdapter.createFromResource(this.getContext(),
R.array.country\u数组,android.R.layout.simple\u微调器\u项);
setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
旋转器。设置适配器(适配器);
spinner.setOnItemSelectedListener(此);
context=getActivity();
minInstance=getActivity();
txtName=(TextView)rootView.findviewbyd(R.id.name);
txtEmail=(TextView)rootView.findviewbyd(R.id.numero_telefonico);
btnLogout=(按钮)rootView.findviewbyd(R.id.btnLogout);
//SqLite数据库处理程序
db=新的SQLiteHandler(context.getApplicationContext());
//会话管理器
session=newsessionmanager(context.getApplicationContext());
/*
如果(!session.isLoggedIn()){
logoutUser();
}
*/
//从SQLite获取用户详细信息
HashMap user=db.getUserDetails();
字符串名称=user.get(“名称”);
//字符串email=user.get(“email”);
//字符串email=user.get(“email”);
字符串email=user.get(“numero_telefonico”);
//在屏幕上显示用户详细信息
System.out.println(姓名+电子邮件);
txtName.setText(名称);
txtEmail.setText(电子邮件);
/*Button mButton=(Button)rootView.findViewById(R.id.Button);
mButton.setOnClickListener(新视图.OnClickListener(){
公共void onClick(视图v){
展示结果(五);
}
});*/
//返回充气机。充气(R.custom_spinner_items.fragment_list2,容器,错误);
btnLogout.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
logoutUser();
}
});
/*微调器微调器=(微调器)getView();
ArrayAdapter_state=新的ArrayAdapter(此,
android.R.layout.simple\u微调器\u项目,状态);
适配器状态
.setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
spinner.setAdapter(适配器状态);
spinner.setOnItemSelectedListener(此)*/
返回rootView;
}
飞机捕捉器:

public abstract class PlanetAdapter extends ArrayAdapter<Planet> implements CompoundButton.OnCheckedChangeListener

{

    private List<Planet> planetList = null;
    private Context context = null;
    ArrayList<Birra> objects;
    public boolean Checked;
    private final Integer[] imageId;

    public PlanetAdapter(List<Planet> planetList, Context context,Integer[] imageId) {

        super(context, R.layout.single_listview_item, planetList);
        this.planetList = planetList;
        this.context = context;
        this.imageId = imageId;
    }


    public class PlanetHolder {
        public TextView planetName;
        public TextView distView;
        public TextView valuta;
        public CheckBox chkBox;
        public EditText edit;
        public TextView caratteristica;
        public boolean checked;
        public TextView id;
        public ImageView imageView;
        public Spinner spinner;
    }

    @Override
    public int getCount() {
        return planetList.size();
    }

    @Override
    public Planet getItem(int position) {
        return planetList.get(position);
    }




    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        View row = convertView;
        PlanetHolder holder = null;

        if (row == null) {
            LayoutInflater inflater = ((Activity) context).getLayoutInflater();
            row = inflater.inflate(R.layout.single_listview_item, parent, false);
            holder = new PlanetHolder();
            holder.planetName = (TextView) row.findViewById(R.id.name);
            holder.distView = (TextView) row.findViewById(R.id.dist);
            holder.valuta = (TextView) row.findViewById(R.id.valuta);
            holder.chkBox = (CheckBox) row.findViewById(R.id.chk_box);
            holder.edit = (EditText) row.findViewById(R.id.editText);
            holder.spinner = (Spinner) row.findViewById(R.id.simpleSpinner);

            holder.caratteristica=(TextView) row.findViewById(R.id.caratteristica);
            holder.imageView = (ImageView) row.findViewById(R.id.ivImage);
            holder.edit.setVisibility(View.GONE);
            holder.edit.setEnabled(false);
            holder.spinner.setVisibility(View.GONE);

            // holder.id = (TextView) row.findViewById(R.id.id);


            row.setTag(holder);

        } else {
            holder = (PlanetHolder) row.getTag();
        }

        final Planet p = planetList.get(position);
        holder.imageView.setImageResource(imageId[position]);
        holder.planetName.setText(p.getName());
        holder.distView.setText("" + p.getDistance());
        holder.valuta.setText("" + p.getValuta());
        holder.chkBox.setChecked(p.isSelected());
        holder.chkBox.setTag(p);
        holder.caratteristica.setText(p.getCaratteristica());
       holder.edit.setEnabled(false);
        SharedPreferences states = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
        boolean isChecked = states.getBoolean("holder.chkBox" + holder.planetName.getText().toString(), false);
        System.out.println(isChecked);
        if (isChecked) {
            holder.chkBox.setChecked(true);
            holder.edit.setVisibility(View.VISIBLE);
            holder.edit.setEnabled(true);
            holder.spinner.setVisibility(View.VISIBLE);

            SharedPreferences statess = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
            String string = statess.getString("finalHolder.edit" + holder.planetName.getText().toString(), holder.edit.getText().toString().trim());
            holder.edit.setText(string);


        } else {
            holder.chkBox.setChecked(false);
            holder.edit.setVisibility(View.GONE);
            holder.edit.setEnabled(false);
            holder.spinner.setVisibility(View.GONE);


         }

        holder.chkBox.setOnCheckedChangeListener(PlanetAdapter.this);
       // final BirraHolder finalHolder = birraHolder;
        final PlanetHolder finalHolder = holder;

        holder.chkBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (finalHolder.chkBox.isChecked()) {
                    finalHolder.edit.setVisibility(View.VISIBLE);
                    finalHolder.edit.setEnabled(true);
                    finalHolder.spinner.setVisibility(View.VISIBLE);
                    SharedPreferences states = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
                    SharedPreferences.Editor editor = states.edit();
                    editor.putBoolean("holder.chkBox" + finalHolder.planetName.getText().toString(), true);
                    editor.commit();
                    finalHolder.edit.addTextChangedListener(new TextWatcher() {
                        @Override
                        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                        }

                        @Override
                        public void onTextChanged(CharSequence s, int start, int before, int count) {
                        }

                        @Override
                        public void afterTextChanged(Editable s) {
                            p.setQuantità(finalHolder.edit.getText().toString().trim());
                            SharedPreferences states = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
                            SharedPreferences.Editor editor = states.edit();
                            editor.putString("finalHolder.edit" + finalHolder.planetName.getText().toString(), finalHolder.edit.getText().toString().trim());
                            editor.commit();


                        }
                    });

                  /*  SharedPreferences states = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
                    SharedPreferences.Editor editor = states.edit();
                    editor.putBoolean("holder.chkBox" + finalHolder.planetName.getText().toString(), true);
                    editor.commit();*/
                    //Utility.putPizzaItem(p);
                    //Utility.getPizzaItem(p);


                } else {
                    finalHolder.edit.setVisibility(View.GONE);
                    finalHolder.edit.setEnabled(false);
                    finalHolder.edit.setText("");
                    finalHolder.spinner.setVisibility(View.GONE);


                }

            }
        });
        /*holder.chkBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (finalHolder.chkBox.isChecked()) {
                    finalHolder.edit.setVisibility(View.VISIBLE);
                    finalHolder.edit.setEnabled(true);
                    SharedPreferences states = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
                    SharedPreferences.Editor editor = states.edit();
                    editor.putBoolean("holder.chkBox", true);
                    //pizzaSelected.put(p.getId(), p);
                    System.out.println(p.getId());
                } else {

                    finalHolder.edit.setVisibility(View.GONE);
                    finalHolder.edit.setEnabled(false);
                    finalHolder.edit.setText(null);
                    pizzaSelected.remove(p.getId());

                }

            }
        });
*/


       /* finalHolder.edit.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                p.setQuantità(finalHolder.edit.getText().toString().trim());
                SharedPreferences states = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
                SharedPreferences.Editor editor = states.edit();
                editor.putString("finalHolder.edit" + finalHolder.planetName.getText().toString(), finalHolder.edit.getText().toString().trim());
                editor.commit();


            }
        });
*/

       // holder.planetName.setText(p.getName());
       // holder.distView.setText("" + p.getDistance());
       // holder.valuta.setText("" + p.getValuta());
       // holder.chkBox.setChecked(p.isSelected());
       // holder.chkBox.setTag(p);
       // holder.edit.setEnabled(false);
        //  holder.id.setId(p.getId());

        return row;
    }

    ArrayList<Planet> getBox() {
        ArrayList<Planet> box = new ArrayList<Planet>();
        for (Planet p : planetList) {
            if (p.isSelected())
                box.add(p);
        }
        return box;
    }



    }
公共抽象类PlanetAdapter扩展ArrayAdapter实现CompoundButton.OnCheckedChangeListener
{
私有列表planetList=null;
私有上下文=null;
阵列列表对象;
公共布尔检查;
私有最终整数[]imageId;
公共PlanetAdapter(列表planetList,上下文上下文,整数[]图像ID){
超级(上下文、右布局、单个列表视图、平面列表);
this.planetList=planetList;
this.context=上下文;
this.imageId=imageId;
}
公共级刨床{
公共文本视图平面名称;
公共文本视图;
公共文本视图valuta;
公共复选框chkBox;
公共编辑文本编辑;
公共文本视图caratteristica;
公共布尔检查;
公共文本视图id;
公共影像视图;
公共微调器;
}
@凌驾
public int getCount(){
返回planetList.size();
}
@凌驾
公共物品(内部位置){
返回飞机列表。获取(位置);
}
@凌驾
公共视图getView(最终整数位置、视图转换视图、视图组父视图){
视图行=转换视图;
刨刀夹持器=空;
if(行==null){
LayoutInflater充气器=((活动)上下文)。getLayoutInflater();
行=充气机。充气(R.layout.single\u listview\u项目,父项,false);
支架=新的刨床支架();
holder.planetName=(TextView)row.findViewById(R.id.name);
holder.distView=(Te)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="1"
    android:layout_marginLeft="5dp"
    ><!--android:onClick="showResult"-->
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:gravity="center"
        android:orientation="horizontal" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/welcome"
        android:textSize="20dp"
        android:layout_marginLeft="5dp"
        />

        <TextView
            android:id="@+id/name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:textColor="@color/lbl_name"
            android:textSize="24dp"
            android:layout_marginLeft="5dp"
            />

    <Button
        android:id="@+id/btnLogout"
        android:layout_width="122dp"
        android:layout_height="wrap_content"
        android:layout_marginRight="40dip"
        android:background="@color/btn_logut_bg"
        android:text="@string/btn_logout"
        android:textAllCaps="false"
        android:textColor="@color/white"
        android:textSize="15dp"
        android:layout_marginLeft="5dp"
        />

</LinearLayout>

    <TextView
        android:id="@+id/numero_telefonico"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/lbl_name"
        android:textSize="13dp" />

    <ListView
        android:id="@+id/listview"
        android:layout_width="fill_parent"
        android:layout_height="400dp">

    </ListView>
    <Spinner
        android:id="@+id/simpleSpinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp"
        android:entries="@array/country_arrays"/>
<!--    <Button
        android:id="@+id/button"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:onClick="showResult"
        android:text="get_answer">
    </Button>-->

    </LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <CheckBox 
        android:id="@+id/chk_box"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true" />
    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:orientation="vertical"
        android:layout_weight="1" >

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/chk_box"
        android:textStyle="bold"
        android:textColor="#000000" />
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/caratteristica"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/name"
                android:layout_toRightOf="@id/chk_box"
                android:textStyle="italic" />
        </LinearLayout>

        <!-- <TextView
             android:id="@+id/id"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginLeft="5dp"
             android:textSize="12sp"
             android:textStyle="italic"/>-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <TextView
        android:id="@+id/dist"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/caratteristica"
        android:layout_toRightOf="@id/chk_box"
        android:textSize="12sp"
        android:textStyle="italic" />
        <TextView
            android:id="@+id/valuta"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:textSize="12sp"
            android:textStyle="italic" />
    </LinearLayout>
    <EditText
        android:layout_width="196dp"
        android:layout_height="wrap_content"
        android:inputType="number"
        android:ems="10"
        android:id="@+id/editText"
        android:hint="quantità"
        >
    </EditText>
        <Spinner
            android:id="@+id/simpleSpinner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="50dp"
            android:entries="@array/country_arrays"/>
    </LinearLayout>
    <ImageView
        android:id="@+id/ivImage"
        android:layout_width="72dp"
        android:layout_height="72dp"
        android:layout_marginRight="5dp"
        android:layout_gravity="center"




        />
</LinearLayout>
public  class MyListAdapter extends ArrayAdapter implements AdapterView.OnItemSelectedListener  {
    Spinner spinner;

    /*public MyListAdapter(Context context, int textViewResourceId) {
        super(context, textViewResourceId);
    }*/

    public MyListAdapter(Context context) {
        super(context, R.layout.single_listview_item);
    }





        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View row = convertView;
            System.out.println("ciao");

            spinner = (Spinner) convertView.findViewById(R.id.simpleSpinner);
            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                    getContext(),
                    R.array.country_arrays,
                    android.R.layout.simple_spinner_item);
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(adapter);
            spinner.setOnItemSelectedListener(this);

/*
            spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
*/
           /*     @Override
                public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                    //Spinner spinner = null;
                   // String selState = (String) ((Spinner) parent).getSelectedItem();

                    spinner.setSelection(position);
                    String selState = (String) ( parent).getSelectedItem();
                    Toast.makeText(
                            parent.getContext(),
                            "Clicked on Planet: " + selState + "", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onNothingSelected(AdapterView<?> parent) {

                }


            });*/



            return row;
        }

    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        spinner.setSelection(position);
        String selState = spinner.getSelectedItem().toString();
        System.out.println(selState);
        Toast.makeText(
                getContext(),
                "Clicked on Planet: " + selState + "", Toast.LENGTH_SHORT).show();
       /* Toast.makeText(parent.getContext(),
                "OnItemSelectedListener : " + parent.getItemAtPosition(position).toString(),
                Toast.LENGTH_SHORT).show();*/
    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {

    }


   /* @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        String selState = (String) spinner.getSelectedItem();
        System.out.println(selState);
        Toast.makeText(
                getContext(),
                "Clicked on Planet: " + selState + "", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {

    }*/

    }
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_list2, container, false);
ListView listView = (ListView) rootView.findViewById(R.id.listview);
ListAdapter listAdapter = new MyListAdapter();
listView.setAdapter(listAdapter);
Spinner spinner = (Spinner) convertView.findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                             getContext(),
                             R.array.country_arrays,
                             android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);