Updated browseable samples for april push
Change-Id: Idd8cc6b7c43ab93f05f0a5d69d5379631721d185
This commit is contained in:
@@ -16,18 +16,22 @@
|
||||
|
||||
package com.example.android.adaptertransition;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* This class provides data as Views. It is designed to support both ListView and GridView by
|
||||
* changing a layout resource file to inflate.
|
||||
*/
|
||||
public class MeatAdapter extends BaseAdapter {
|
||||
public class MeatAdapter extends BaseAdapter implements AbsListView.OnItemClickListener {
|
||||
|
||||
private final LayoutInflater mLayoutInflater;
|
||||
private final int mResourceId;
|
||||
@@ -80,6 +84,16 @@ public class MeatAdapter extends BaseAdapter {
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
ViewHolder holder = (ViewHolder) view.getTag();
|
||||
Context context = view.getContext();
|
||||
if (null != holder && null != holder.title && null != context) {
|
||||
Toast.makeText(context, context.getString(R.string.item_clicked,
|
||||
holder.title.getText()), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private static class ViewHolder {
|
||||
public ImageView image;
|
||||
public TextView title;
|
||||
|
||||
Reference in New Issue
Block a user