在我的customarrayadapter视图中,我有一个微调器。如果选择了微调器的其中一个项目,它将获得主Listview的当前位置。我无法获得Listview上当前项目的位置,其中微调器处于活动状态。它将只显示位置-1。
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
Viewholder v = new Viewholder();
v.rowView = convertView;
v.spinner = (Spinner)v.rowView.findViewById(R.id.spinner1);
v.spinner.setOnItemSelectedListener( new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
//Attempt code v.spinner = (Spinner)v.rowView.findViewById(R.id.spinner1);
Toast.makeText(getActivity(), "Position " + listview.getSelectedItemPosition(), Toast.LENGTH_LONG).show();
}
答案 0 :(得分:0)
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
Viewholder v = new Viewholder();
v.rowView = convertView;
v.spinner = (Spinner)v.rowView.findViewById(R.id.spinner1);
v.spinner.setOnItemSelectedListener( new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int arg, long id) {
// TODO Auto-generated method stub
//Attempt code v.spinner = (Spinner)v.rowView.findViewById(R.id.spinner1);
Toast.makeText(getActivity(), "Position " + position, Toast.LENGTH_LONG).show();
}
答案 1 :(得分:0)
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
final int listview_position=position;
Viewholder v = new Viewholder();
v.rowView = convertView;
v.spinner = (Spinner)v.rowView.findViewById(R.id.spinner1);
v.spinner.setOnItemSelectedListener( new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
//Attempt code v.spinner = (Spinner)v.rowView.findViewById(R.id.spinner1);
Toast.makeText(getActivity(), "Position " + listview_position,Toast.LENGTH_LONG).show();
}
}
}
答案 2 :(得分:0)
您的问题没有旋转,arrayadapter使用相同的名称。您也可以只更改名称
@Override
public View getView(final int listview_position, View convertView, final ViewGroup parent) {
Viewholder v = new Viewholder();
v.rowView = convertView;
v.spinner = (Spinner)v.rowView.findViewById(R.id.spinner1);
v.spinner.setOnItemSelectedListener( new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int spinner_position, long id) {
// TODO Auto-generated method stub
//Attempt code v.spinner = (Spinner)v.rowView.findViewById(R.id.spinner1);
Toast.makeText(getActivity(), "Position " + listview_position, Toast.LENGTH_LONG).show();
}