我想将数组复制到数组。有可能这样吗?
我想从数组“arrayList data”中获取一些值
在该数组中包含一个值
我将 inkLevels 声明为我的数组,以便为第三行设置值。我只需要最后一行的值。在 GetInkLevel 内部。我有一些方法,但我确定这不是好方法。你有什么建议吗?
public class ActivityToSmartWatch extends BaseAdapter {
private Activity activity;
private ArrayList<String[]> data;
private static LayoutInflater inflater = null;
private String[] inkLevels = new String[5];
public ActivityToSmartWatch(Activity a, ArrayList<String[]> inkLevels) {
activity = a;
data = inkLevels;
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
if (convertView == null)
vi = inflater
.inflate(R.layout.listviewitem_ink, null);
if (data.get(position)[0].equals("C"))
{
TextView inkLevel = (TextView)vi.findViewById(R.id.lvi_colorLevel);
inkLevel.setText(data.get(position)[2]);
}
else if (data.get(position)[0].equals("Y"))
{
TextView inkLevel = (TextView)vi.findViewById(R.id.lvi_colorLevel);
inkLevel.setText(data.get(position)[2]);
}
else if (data.get(position)[0].equals("M"))
{
TextView inkLevel = (TextView)vi.findViewById(R.id.lvi_colorLevel);
inkLevel.setText(data.get(position)[2]);
}
else if (data.get(position)[0].equals("B"))
{
TextView inkLevel = (TextView)vi.findViewById(R.id.lvi_colorLevel);
inkLevel.setText(data.get(position)[2]);
}
return vi;
}
public String[] getInkLevel (String [] inkLevels, int position)
{
for (int i= 0; i <data.size(); i++)
{
inkLevels[i] = data.get(i);
}
return inkLevels;
}
}