已定义MySimpleAdapter类型

时间:2013-04-18 13:59:09

标签: java android eclipse

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

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;

} }

1 个答案:

答案 0 :(得分:0)

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