У меня есть список действий, в котором я показываю изображение и текст в ряд.
Изображения статичны и помещаются в папку для рисования.
Я хочу напечатать изображения и текст в следующем упражнении, нажимая на элемент списка.Я могу успешно отправить текстовое представление о следующей деятельности.Но мне было трудно отправить изображение в следующее окно.Потому что это статично.
Может кто-нибудь помочь мне в этом вопросе.Заранее спасибо.
public class Myimage extends ListActivity {
private LayoutInflater mInflater;
static Vector<RowData> data = new Vector<RowData>();
RowData rd;
static boolean fromCategory = false;
static final String[] title = new String[] {
"One", "Two", "Three "};
private Integer[] img = {
R.drawable.i,R.drawable.im,R.drawable.ima};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mInflater =
(LayoutInflater) getSystemService(
Activity.LAYOUT_INFLATER_SERVICE);
for(int i=0;i<title.length;i++){
try {
rd = new RowData(i,title[i]);
} catch (Exception e) {
e.printStackTrace();
}
data.add(rd);
}
CustomAdapter adapter = new CustomAdapter(this, R.layout.list,
R.id.title, data);
setListAdapter(adapter);
getListView().setTextFilterEnabled(true);
// This is the List Item Click method which i should work to send the image on next activity.
public void onListItemClick(ListView parent, View v, int position,
long id) {
Intent intent = new Intent(this,Second.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
public class RowData {
protected int mId;
protected String mTitle;
RowData(int id,String title){
mId=id;
mTitle = title;
}
public void setTitle(String title) {
this.mTitle = title.trim();
}
public String getTitle() {
return mTitle;
}
public void setId(int i){
this.mId=i;
}
public int getId(){
return mId;
}
@Override
public String toString() {
return mId+" "+mTitle;
}
}
private class CustomAdapter extends ArrayAdapter<RowData> {
public CustomAdapter(Context context, int resource,
int textViewResourceId, List<RowData> objects) {
super(context, resource, textViewResourceId, objects);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
TextView title = null;
ImageView i11=null;
RowData rowData= getItem(position);
if(null == convertView){
convertView = mInflater.inflate(R.layout.list, null);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
}
holder = (ViewHolder) convertView.getTag();
title = holder.gettitle();
title.setText(rowData.mTitle);
i11=holder.getImage();
i11.setImageResource(img[rowData.mId]);
return convertView;
}
private class ViewHolder {
private View mRow;
private TextView title = null;
private ImageView i11=null;
public ViewHolder(View row) {
mRow = row;
}
public TextView gettitle() {
if(null == title){
title = (TextView) mRow.findViewById(R.id.title);
}
return title;
}
public ImageView getImage() {
if(null == i11){
i11 = (ImageView) mRow.findViewById(R.id.img);
}
return i11;
}
}
} }