将微调框小部件附加到回收站视图(Android)

时间:2017-09-06 10:18:58

标签: android android-recyclerview spinner

我想在我的Recycler视图中添加多个微调器,我使用解析作为我的后端,我已经创建了一个,但这并没有给我预期的结果。而且我也不知道怎么办onclick如果我的项目列在微调器下面是我的代码

public class Online3 extends AppCompatActivity {


List<String> categories1, categories2, categories3, categories4, categories13, categories12, categories5, categories6;
String objectId;
private List<Array_G_S> list = new ArrayList<>();
RecyclerView recyclerView;
ArrayAdap adapter;

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


    Intent intent = getIntent();
    objectId = intent.getStringExtra("objId");
    String txt = intent.getStringExtra("imageText");
    if (objectId != null) {
        Log.i("sand", objectId);
    } else {
        Log.i("sand", txt);
    }
    new RemoteTask().execute();

}

private class RemoteTask extends AsyncTask<Void, Void, Void> {
    @Override
    protected Void doInBackground(Void... params) {

        ParseQuery<ParseObject> query = new ParseQuery<>("OnlineShopping");
        query.whereEqualTo("objectId", objectId);


        List<ParseObject> object1 = null;
        try {
            object1 = query.find();
            for (final ParseObject country : object1) {

                if (country != null) {

                    ParseRelation<ParseObject> p = country.getRelation("arrayRelation");

                    ParseQuery p2 = p.getQuery();
                    List<ParseObject> oc = p2.find();

                    for (ParseObject country2 : oc) {

                        if (country2 != null) {
                            categories1 = country2.getList("eType");

                            Array_G_S gs = new Array_G_S();
                            gs.setStringList(categories1);
                            list.add(gs);


                        }

                    }
                }
                // Locate images in flag column

            }
        } catch (com.parse.ParseException e1) {
            e1.printStackTrace();
        }

        return null;
    }

    @Override
    protected void onPostExecute(Void aVoid) {
        recyclerView = (RecyclerView) findViewById(R.id.arrayRecy);
        recyclerView.setNestedScrollingEnabled(false);                                              // Smooth Scrolling
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
        adapter = new ArrayAdap(getApplicationContext(), list);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.setAdapter(adapter);

    }
}   

以下是我的适配器类

public class ArrayAdap extends RecyclerView.Adapter<ArrayAdap.MyViewHolder> {

private Context context;
private List<Array_G_S> list = null;
 ArrayAdapter<Array_G_S> dataAdapter;


public ArrayAdap(Context context, List<Array_G_S> list) {

    this.context = context;
    this.list = list;

}


@Override
public ArrayAdap.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.spinner, parent, false);
    return new MyViewHolder(itemView);
}

@Override
public void onBindViewHolder(ArrayAdap.MyViewHolder holder, int position) {
     Array_G_S gs = list.get(position);
    dataAdapter =  new ArrayAdapter<String>(context,android.R.layout.simple_spinner_item,gs.getStringList());

    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    holder.spinner.setAdapter(dataAdapter);
}

@Override
public int getItemCount() {
    return list.size();
}

public class MyViewHolder extends RecyclerView.ViewHolder {
    Spinner spinner;
    public MyViewHolder(View v) {
        super(v);
        spinner = (Spinner) v.findViewById(R.id.spin);


    }
}  

这是我得到的截图

enter image description here

修改
我已经编辑了上面的代码 好的,我已经通过将Getter_Setter列表直接放到适配器来解决了这个问题。 现在我的问题是如何解决所选项目的Onclick 的修改
这只是创建一个微调器,我需要多个微调器,即根据我的列表

0 个答案:

没有答案