0

此类已在另一个名为“Expenses_act.java”的 java 文件中定义。我需要能够让它在一个名为“Incomes_act.java”的文件中运行。这是一个安卓应用程序。我怎样才能做到这一点?

class MySimpleAdapter extends ArrayAdapter<String> {
private final Context context;
private final ArrayList<String> values;


public MySimpleAdapter(Context context, List<String> values)
{
    super(context, R.layout.custom_row, values);
    this.context = context;
    this.values = (ArrayList<String>) 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.custom_row, parent, false);
TextView textView1 = (TextView) rowView.findViewById(R.row.date);
TextView textView2 = (TextView) rowView.findViewById(R.row.time);
TextView textView3 = (TextView) rowView.findViewById(R.row.desc);
TextView textView4 = (TextView) rowView.findViewById(R.row.val);
TextView textView5 = (TextView) rowView.findViewById(R.row.cat);


String[] split = values.get(position).split(";");
final String PREFS_NAME = "Sets";
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
textView1.setText(split[0] + " ");
textView2.setText(split[1] + " ");
textView3.setText(split[2] + " ");
textView4.setText(settings.getString("SelectedCur", "ˆ")+split[3] + " ");
textView5.setText(split[4] + " ");

return rowView;

} }

4

1 回答 1

0

公开 MySimpleAdapter 类。我认为您现有的适配器类位于不同的包中。所有类的默认访问修饰符是包,它允许包中的所有类访问它。

于 2013-04-18T14:02:33.003 回答