これは私のListViewです:
このリストビューをスクロールして、たとえば[非表示]をクリックすると、[お気に入り]アクションが呼び出されます(同様のバグ-[圧縮]を押すと、他の何かが呼び出されます)。
これは、スクロール後にのみ発生します。ListViewをスクロールしないと絶対にありません。
これは私のアダプターです:
package com.landa.adapter;
import java.util.ArrayList;
import com.example.fileexplorermanager.R;
import com.landa.dialog.OperationsDialogFragment;
public class OperationsAdapter extends ArrayAdapter<String> {
private final Context context;
private final ArrayList<String> data;
public OperationsAdapter(Context context, ArrayList<String> values) {
super(context, R.layout.operations_list_item, values);
this.context = context;
this.data = values;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//View rowView = inflater.inflate(R.layout.operations_list, parent, false);
View rowView = inflater.inflate(R.layout.operations_list_item, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.operation_name);
String temp = data.get(position);
String op_name = temp;
textView.setText(op_name);
ImageView imageView = (ImageView) rowView.findViewById(R.id.operation_image);
return rowView;
}
public int getCount() {
return data.size();
}
}
これはダイアログです(ListViewはダイアログ内にあります):
public class OperationsDialogFragment extends DialogFragment {
// operation names
public static final String OP_CUT = "Cut";
public static final String OP_COPY = "Copy";
public static final String OP_RENAME = "Rename";
public static final String OP_DELETE = "Delete";
public static final String OP_SELECT_ALL = "Select all";
public static final String OP_SELECT_INVERSE = "Select inverse";
public static final String OP_CREATE_SHORTCUT = "Create shortcut";
public static final String OP_FAVORITE = "Favorite";
public static final String OP_HIDE = "Hide";
public static final String OP_COMPRESS = "Compress";
public static final String OP_SET_AS_HOME = "Set as home";
public static final String OP_PROPERTIES = "Properties";
ArrayList<String> operationsInfo = new ArrayList<String>();
private OperationsHandler opHandler;
private File f;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
opHandler = OperationsHandler.getInstance();
final String operation_type = getArguments().getString("operation_type");
final String file_absolute_path = getArguments().getString("file_absolute_path");
if(file_absolute_path != null)
this.f = new File(file_absolute_path);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
ArrayList<String> operationsList;
if (operation_type.equals("single_file")) {
setSingleFileDialogTitle(builder);
operationsList = getSingleFileOperationsList();
} else if (operation_type.equals("multiple_files")) {
setDefaultDialogTitle(builder);
operationsList = getMultipleFilesOperationsList();
} else {
setDefaultDialogTitle(builder);
operationsList = getDefaultOperationsList();
}
OperationsAdapter adap = new OperationsAdapter(getActivity(),
operationsList);
// upon operation click, execute operation
builder.setAdapter(adap, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String op_name = getOperationName(((AlertDialog) dialog)
.getListView().getChildAt(whichButton));
if (operation_type.equals("single_file")) {
executeSingleFileOperation(op_name);
} else {
executeMultipleFilesOperation(op_name);
}
}
});
return builder.create();
}
何が間違っている可能性がありますか?