How can i use the method getChildFragmentManager() in a custom adapter that extends ArrayAdapter<> ?
Here's my code if you need to see it:
MyAdapter.java:
public class MyAdapter extends ArrayAdapter<Content> {
Context context;
List<Content> myList;
public static final String pattern = "(?<=watch\\?v=|/videos/|embed\\/)[^#\\&\\?]*";
public MyAdapter(Context context, int resource, List<Content> objects) {
super(context, resource, objects);
this.context = context;
this.myList = objects;
}
#Override
public int getCount() {
if (myList != null)
return myList.size();
return 0;
}
#Override
public Content getItem(int position) {
if (myList != null)
return myList.get(position);
return null;
}
#Override
public long getItemId(int position) {
if (myList != null)
return myList.get(position).hashCode();
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder holder;
if (convertView == null) {
holder = new Holder();
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.list_item, null);
holder.contId = (TextView) convertView.findViewById(R.id.content_id);
holder.contType = (TextView) convertView.findViewById(R.id.type);
holder.txtTitle = (TextView) convertView.findViewById(R.id.title);
holder.txtTeaser = (TextView) convertView.findViewById(R.id.teaser);
holder.imageView = (ImageView) convertView.findViewById(R.id.cover_photo);
holder.youTubeVideo = (FrameLayout) convertView.findViewById(R.id.youTube_frame);
convertView.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
}
Content content = getItem(position);
holder.contId.setText(content.getId());
holder.contType.setText(content.getType());
holder.txtTitle.setText(content.getTitle());
holder.txtTeaser.setText(content.getTeaser());
Picasso.with(context).load(Uri.parse(content.getImageUrl())).into(holder.imageView);
if(content.getCoverVideo() != null && !content.getCoverVideo().equals("")){
String cover_video = content.getCoverVideo();
Pattern compiledPattern = Pattern.compile(pattern);
Matcher matcher = compiledPattern.matcher(cover_video);
if(matcher.find()){
cover_video = matcher.group();
}
Bundle youTubeBundle = new Bundle();
youTubeBundle.putString("link", cover_video);
FragmentManager manager = getChildFragmentManager(); // <------ Can't resolve method
FragmentTransaction transaction = manager.beginTransaction();
ArticleYouTubeFragment youtubeFragment = new ArticleYouTubeFragment();
youtubeFragment.setArguments(youTubeBundle);
transaction.replace(R.id.list_youTube_frame, youtubeFragment);
transaction.commit();
}
return convertView;
}
private class Holder {
TextView contId;
TextView contType;
TextView txtTitle;
TextView txtTeaser;
ImageView imageView;
FrameLayout youTubeVideo;
}
}
Thanks in advance.
Related
I am trying to create a custom adapter for a shop element in my Android app but every time I scroll down the list the images seem to change their position, I have had a look around on here already but suggestions that I have found and tried have been to no avail.
Each item has a title, an image (being loading via an AsyncTask or retrieved from the LRUCache) and a price of the item below is the code I use to generate the adapter.
public class ShopAdapter extends BaseAdapter {
public Context context;
public ArrayList<ShopItem> shopItemList;
public ImageCache imageCache;
String imageToLoad;
Bitmap shopImage;
public ShopAdapter(Context context, ArrayList<ShopItem> shopItemList) {
this.context = context;
this.shopItemList = shopItemList;
imageCache = new ImageCache(this.context);
}
#Override
public int getCount() {
return shopItemList.size();
}
#Override
public Object getItem(int position) {
return shopItemList.get(position);
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if(convertView == null){
LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.shop_list, null);
holder = new ViewHolder();
holder.title = (TextView) convertView.findViewById(R.id.textView3);
holder.image =(ImageView) convertView.findViewById(R.id.imageView);
holder.price = (TextView) convertView.findViewById(R.id.textView4);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.title.setText(shopItemList.get(position).getTitle());
shopImage = imageCache.getBitmapFromMemoryCache(shopItemList.get(position).getImage());
if(shopImage != null) {
holder.image.setImageBitmap(shopImage);
} else {
new LoadImage(context, holder.image).execute(imageToLoad);
}
holder.price.setText(shopItemList.get(position).getPrice());
return convertView;
}
static class ViewHolder {
TextView title;
ImageView image;
TextView price;
}
}
Any help would be very much appreciated!
My listview isn't updating correctly when I try to remove or copy an item. The data is storing correctly in the database, but is not displayed correctly on the listview, which I think is due to issues with recycling views.
For example, I deleted an item with id 87, then I copied a different item and it showed up in the listview as having an id of 87 even though it should have been 88 (and was correctly stored in the db as 88).
I've tried looking at some other examples of code with view holders and custom adapters, but I can't seem to figure out the issue. Have I applied the ViewHolder concept correctly to my custom adapter?
public class WorkoutAdapter extends ArrayAdapter<ExerciseSetModel> {
private Context context;
private ArrayList<ExerciseSetModel> exerciseSetList;
private JSONParser jParser = new JSONParser();
private String isComplete;
private String exerciseId;
public WorkoutAdapter(Context context, ArrayList<ExerciseSetModel> objects) {
super(context, R.layout.exercise_set_item, objects);
this.context = context;
this.exerciseSetList = objects;
isComplete = "";
}
private class ViewHolder{
TextView tvExerciseSetName;
TextView tvExerciseSetDetails;
CheckBox cbIsComplete;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
RelativeLayout view = (RelativeLayout) convertView;
ViewHolder holder = null;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (RelativeLayout) inflater.inflate(R.layout.exercise_set_item, parent, false);
holder = new ViewHolder();
holder.tvExerciseSetName = (TextView) view.findViewById(R.id.exerciseSetName);
holder.tvExerciseSetDetails = (TextView) view.findViewById(R.id.exerciseSetDetails);
holder.cbIsComplete = (CheckBox) view.findViewById(R.id.cbIsComplete);
if (exerciseSetList.get(position).getIsComplete() == 1) {
holder.cbIsComplete.setChecked(true);
isComplete = "1";
}
else {
holder.cbIsComplete.setChecked(false);
isComplete = "0";
}
holder.cbIsComplete.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
exerciseSetList.get(position).setIsComplete(1);
exerciseId = exerciseSetList.get(position).getExerciseId() + "";
isComplete = "1";
} else {
exerciseSetList.get(position).setIsComplete(0);
exerciseId = exerciseSetList.get(position).getExerciseId() + "";
isComplete = "0";
}
new UpdateExerciseComplete().execute();
}
});
holder.tvExerciseSetName.setText(exerciseSetList.get(position).getExerciseName());
holder.tvExerciseSetDetails.setText(exerciseSetList.get(position).getExerciseDetails() + " id: " + exerciseSetList.get(position).getExerciseId());
}
else{
holder = (ViewHolder) view.getTag();
}
return view;
}
class UpdateExerciseComplete extends AsyncTask<String, String, String> {
private String updateIsCompleteUrl;
#Override
protected void onPreExecute() {
super.onPreExecute();
}
protected String doInBackground(String... args) {
updateIsCompleteUrl = "localhost/android_connect/updateIsComplete.php";
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
params.put("is_complete", isComplete);
params.put("exercise_id", exerciseId);
jParser.makePostRequest(updateIsCompleteUrl, params);
return null;
}
protected void onPostExecute(String file_url) {
}
}
}
You have implemented wrong ViewHolder pattern. replace modified getView
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
RelativeLayout view = (RelativeLayout) convertView;
ViewHolder holder = null;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (RelativeLayout) inflater.inflate(R.layout.exercise_set_item, parent, false);
holder = new ViewHolder();
holder.tvExerciseSetName = (TextView) view.findViewById(R.id.exerciseSetName);
holder.tvExerciseSetDetails = (TextView) view.findViewById(R.id.exerciseSetDetails);
holder.cbIsComplete = (CheckBox) view.findViewById(R.id.cbIsComplete);
view.setTag(holder);
}else{
holder = (ViewHolder) view.getTag();
}
if (exerciseSetList.get(position).getIsComplete() == 1) {
holder.cbIsComplete.setChecked(true);
isComplete = "1";
}
else {
holder.cbIsComplete.setChecked(false);
isComplete = "0";
}
holder.cbIsComplete.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
exerciseSetList.get(position).setIsComplete(1);
exerciseId = exerciseSetList.get(position).getExerciseId() + "";
isComplete = "1";
} else {
exerciseSetList.get(position).setIsComplete(0);
exerciseId = exerciseSetList.get(position).getExerciseId() + "";
isComplete = "0";
}
new UpdateExerciseComplete().execute();
}
});
holder.tvExerciseSetName.setText(exerciseSetList.get(position).getExerciseName());
holder.tvExerciseSetDetails.setText(exerciseSetList.get(position).getExerciseDetails() + " id: " + exerciseSetList.get(position).getExerciseId());
return view;
}
For getting correct position in onclick() function. you have to tag position on your view holder.cbIsComplete.setTag(position) then get this tag inside onCLick() using int position=(Integer)buttonView.getTag()
I try create multi ListView but I have java.lang.NullPointerException. It seems to be alright.
Main:
for(int i = 0; i < 10; i++) {
ActivityObject ao = new ActivityObject();
if(i%2 == 0) {
ao.setType("0");
ao.setTitle("Im null");
} else {
ao.setType("1");
ao.setTitle("Im one");
}
dataActivity.add(ao);
}
ActivityAdapter adapter = new ActivityAdapter(getApplicationContext(), dataActivity);
listActivity.setAdapter(adapter);
Super Adapter
public class ActivityAdapter extends ArrayAdapter {
private Context context;
private ArrayList<ActivityObject> object;
LayoutInflater vi;
public ActivityAdapter(Context context, ArrayList<ActivityObject> object) {
super(context, 0, object);
this.context = context;
this.object = object;
vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if(convertView == null) {
if(object.get(position).equals("0")) {
convertView = vi.inflate(R.layout.p_activity_detected, null);
holder.textActivity = (TextView) convertView.findViewById(R.id.detected_text);
}
if(object.get(position).equals("1")) {
convertView = vi.inflate(R.layout.p_activity_people, null);
holder.textPeople = (TextView) convertView.findViewById(R.id.people_text);
}
holder = new ViewHolder();
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
//set text
if(object.get(position).getType().equals("0")) {
holder.textActivity.setText(object.get(position).getTitle());
}
if(object.get(position).getType().equals("1")) {
holder.textPeople.setText(object.get(position).getTitle());
}
return convertView;
}
static class ViewHolder {
public TextView textActivity;
public TextView textPeople;
}
}
Error
FATAL EXCEPTION: main
java.lang.NullPointerException
at adapters.ActivityAdapter.getView(ActivityAdapter.java:54)
this is line
convertView.setTag(holder);
Replace yours adapter with these code
public class ActivityAdapter extends ArrayAdapter {
private Context context;
private ArrayList<ActivityObject> object;
LayoutInflater vi;
ViewHolder holder;
public ActivityAdapter(Context context, ArrayList<ActivityObject> object) {
super(context, 0, object);
this.context = context;
this.object = object;
vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
holder = new ViewHolder();;
if(convertView == null) {
if(object.get(position).equals("0")) {
convertView = vi.inflate(R.layout.p_activity_detected, null);
holder.textActivity = (TextView) convertView.findViewById(R.id.detected_text);
}
if(object.get(position).equals("1")) {
convertView = vi.inflate(R.layout.p_activity_people, null);
holder.textPeople = (TextView) convertView.findViewById(R.id.people_text);
}
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
//set text
if(object.get(position).getType().equals("0")) {
holder.textActivity.setText(object.get(position).getTitle());
}
if(object.get(position).getType().equals("1")) {
holder.textPeople.setText(object.get(position).getTitle());
}
return convertView;
}
static class ViewHolder {
public TextView textActivity;
public TextView textPeople;
}
}
Move your holder on top. I think it will works. In my opinion you also have to use else statement.
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if(convertView == null) {
holder = new ViewHolder();
Log.d("object.get(position) = ", object.get(position));
if(object.get(position).equals("0")) {
convertView = vi.inflate(R.layout.p_activity_detected, null);
holder.textActivity = (TextView) convertView.findViewById(R.id.detected_text);
}
else if(object.get(position).equals("1")) {
convertView = vi.inflate(R.layout.p_activity_people, null);
holder.textPeople = (TextView) convertView.findViewById(R.id.people_text);
}
else{
//set defualt holder.textPeople here
}
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
//set text
if(object.get(position).getType().equals("0")) {
holder.textActivity.setText(object.get(position).getTitle());
}
if(object.get(position).getType().equals("1")) {
holder.textPeople.setText(object.get(position).getTitle());
}
return convertView;
}
There is no guarantee in your code that convertView will not be null:
if(convertView == null) {
if(object.get(position).equals("0")) {
convertView = vi.inflate(R.layout.p_activity_detected, null);
holder.textActivity = (TextView) convertView.findViewById(R.id.detected_text);
}
if(object.get(position).equals("1")) {
convertView = vi.inflate(R.layout.p_activity_people, null);
holder.textPeople = (TextView) convertView.findViewById(R.id.people_text);
}
holder = new ViewHolder();
convertView.setTag(holder);
If none of the conditions above hold true, then convertView will still be null.
Are you sure the conditions are exactly what you want to do?
According to your declaration
private ArrayList<ActivityObject> object;
object is a list of ActivityObject, but you are comparing them with the strings "0" and "1" in
object.get(position).equals("0"))
...
object.get(position).equals("1"))
Maybe you want to cast them into ActivityObject and the compare the field in type with the strings?
When I am checked any item like (position 0) its automatically checked randomly any item (like position 7) and when I scroll down or up the check position will be change every time... I am fed up from that problem...??
public class contactAdpter extends ArrayAdapter<ContactItem> {
Context context;
List<ContactItem> list;
public contactAdpter(Context context, int resource, List<ContactItem> items) {
super(context, resource,items);
this.context = context;
this.list = items;
}
static class ViewHolder {
ImageView imageview;
TextView tv1;
TextView tv2;
CheckBox ch;
}
#Override
public int getCount() {
return list.size();
}
#Override
public int getPosition(ContactItem item) {
return super.getPosition(item);
}
#Override
public long getItemId(int id) {
return id;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder=null;
View view = convertView;
ContactItem contactItem = getItem(position);
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
view = mInflater.inflate(R.layout.contact_list, null);
holder = new ViewHolder();
holder.tv1 = (TextView) view.findViewById(R.id.name);
holder.tv2 = (TextView) view.findViewById(R.id.number);
holder.ch = (CheckBox) view.findViewById(R.id.checkbox1);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
holder.tv1.setText(contactItem.getConatct_name());
holder.tv2.setText(contactItem.getNumber());
return view;
}
}
in ContactItem you need to maintain Checked Status. and change getView as follows,
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder=null;
View view = convertView;
ContactItem contactItem = getItem(position);
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
view = mInflater.inflate(R.layout.contact_list, null);
holder = new ViewHolder();
holder.tv1 = (TextView) view.findViewById(R.id.name);
holder.tv2 = (TextView) view.findViewById(R.id.number);
holder.ch = (CheckBox) view.findViewById(R.id.checkbox1);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
holder.tv1.setText(contactItem.getConatct_name());
holder.tv2.setText(contactItem.getNumber());
holder.ch.setOnCheckedChangeListener(null);
holder.ch.setChecked(contactItem.getCheckedStatus());
holder.ch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
contactItem.setCheckedStatus(isChecked);
}
});
return view;
}
you have to add another variable in ContactItem like below:
private boolean isSelected;
generate getter and setter method of this variable after that in your adapter :
public class contactAdpter extends ArrayAdapter {
Context context;
List<ContactItem> list;
public contactAdpter(Context context, int resource, List<ContactItem> items) {
super(context, resource,items);
this.context = context;
this.list = items;
}
static class ViewHolder {
ImageView imageview;
TextView tv1;
TextView tv2;
CheckBox ch;
}
#Override
public int getCount() {
return list.size();
}
#Override
public int getPosition(ContactItem item) {
return super.getPosition(item);
}
#Override
public long getItemId(int id) {
return id;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder=null;
View view = convertView;
ContactItem contactItem = getItem(position);
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
view = mInflater.inflate(R.layout.contact_list, null);
holder = new ViewHolder();
holder.tv1 = (TextView) view.findViewById(R.id.name);
holder.tv2 = (TextView) view.findViewById(R.id.number);
holder.ch = (CheckBox) view.findViewById(R.id.checkbox1);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
holder.tv1.setText(contactItem.getConatct_name());
holder.tv2.setText(contactItem.getNumber());
if(contactItem.isSelected){
holder.ch.isChecked(true);
} else {
holder.ch.isChecked(false);
}
holder.ch.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(contactItem.isSelected){
holder.ch.isChecked(false);
contactItem.setChecked(false);
} else {
holder.ch.isChecked(true);
contactItem.setChecked(true);
}
notifyDatasetChanged();
}
});
return view;
}
}
I have
public class MainActivity extends FragmentActivity
I wrote Loader class which implements AsyncResponse:
public class Loader implements AsyncResponse {
public Activity contextActivity;
Loader(Activity context) {
this.contextActivity = context;
}
Class "Loader" has method "DrawTabInfo" which calling from AsyncResponse callback.
public void drawTabInfo(String jsonBlob, int tabId)
{
JSONObject dataJsonObj;
PullToRefreshListView list = null;
try {
dataJsonObj = new JSONObject(jsonBlob);
JSONArray jsonData = dataJsonObj.getJSONArray("steals");
ArrayList<JSONObject> data = new ArrayList<JSONObject>();
for (int i=0;i<jsonData.length();i++){
data.add(jsonData.getJSONObject(i));
}
Adapter adapter = new Adapter(contextActivity, data);
LayoutInflater inflater = LayoutInflater.from(contextActivity);
if (tabId == 0) {
View view = inflater.inflate(R.layout.listviewlayout, null, false);
list = (PullToRefreshListView) view.findViewById(R.id.listView);
}
if (tabId == 1) {
View view = inflater.inflate(R.layout.listviewlayout2, null, false);
list = (PullToRefreshListView) view.findViewById(R.id.listView2);
}
list.setAdapter(adapter);
adapter.setNotifyOnChange(true);
Log.d("COUNT") shows - "4", what means array is built fine.
public class Adapter extends ArrayAdapter<JSONObject> {
private final Activity context;
private final ArrayList<JSONObject> profiles;
public String header;
public String preText;
public String imageURL;
static class ViewHolder {
public TextView header;
public ImageView image;
public TextView preText;
public LinearLayout linearItemLayout;
}
public Adapter(Activity context, ArrayList<JSONObject> array) {
super(context, R.layout.tab1_list_layout, array);
Log.d("ADAPTER", "SETTING ADAPTER");
this.context = context;
this.profiles = array;
Log.d("COUNT", "" + profiles.size());
}
#Override
public int getCount()
{
return profiles.size();
}
My getView method:
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
Log.i("GetView Log", "Adapters GetView hasbeen called");// thats never calling
if (rowView == null) {
LayoutInflater inflater = context.getLayoutInflater();
rowView = inflater.inflate(R.layout.tab1_list_layout, null);
ViewHolder viewHolder = new ViewHolder();
viewHolder.linearItemLayout = (LinearLayout) rowView.findViewById(R.id.linearItemLayout);
viewHolder.header = (TextView) rowView.findViewById(R.id.itemHeader);
viewHolder.image = (ImageView) rowView.findViewById(R.id.itemPreImage);
viewHolder.preText = (TextView) rowView.findViewById(R.id.itemPreText);
rowView.setTag(viewHolder);
}
ViewHolder holder = (ViewHolder) rowView.getTag();
JSONObject item = null;
try {
item = profiles.get(position);
header = item.getString("header");
preText = item.getString("previewText");
imageURL = item.getString("previewImageUrl");
} catch (JSONException e) {
e.printStackTrace();
}
Log.d("ADAPTER LOG", header);
holder.header.setText(header);
holder.preText.setText(preText);
int headerHeight = (int) Math.round(header.length() * 1.5);
holder.linearItemLayout.setMinimumHeight(40 + headerHeight + preText.length());
Picasso.with(context).setIndicatorsEnabled(true);
Picasso.with(context).load(imageURL).resize(140,100).into(holder.image);
return rowView;
}
In MainActivity i calling, where "this" = MainActivity;
Loader loader = new Loader(this);
loader.loadTabInfo(0);
Method getView never calling. What I'am doing wrong?
UPD:
Solved:
public void drawTabInfo(String jsonBlob, int tabId)
{
JSONObject dataJsonObj;
PullToRefreshListView list = null;
try {
dataJsonObj = new JSONObject(jsonBlob);
JSONArray jsonData = dataJsonObj.getJSONArray("steals");
ArrayList<JSONObject> data = new ArrayList<JSONObject>();
for (int i=0;i<jsonData.length();i++){
data.add(jsonData.getJSONObject(i));
}
Adapter adapter = new Adapter(contextActivity, data);
//LayoutInflater inflater = LayoutInflater.from(contextActivity);
if (tabId == 0) {
//View view = inflater.inflate(R.layout.listviewlayout, null, false);
list = (PullToRefreshListView) contextActivity.findViewById(R.id.listView);
Your code is fine .. just you need a little bit change in get view method
add a return statement.. like return rowView;
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
Log.d("GETVIEaW", "GETVIEW");
if (rowView == null) {
LayoutInflater inflater = context.getLayoutInflater();
rowView = inflater.inflate(R.layout.tab1_list_layout, null);
ViewHolder viewHolder = new ViewHolder();
viewHolder.linearItemLayout = (LinearLayout) rowView.findViewById(R.id.linearItemLayout);
viewHolder.header = (TextView) rowView.findViewById(R.id.itemHeader);
viewHolder.image = (ImageView) rowView.findViewById(R.id.itemPreImage);
viewHolder.preText = (TextView) rowView.findViewById(R.id.itemPreText);
rowView.setTag(viewHolder);
}
else{
viewHolder = (ViewHolder) rowView.getTag();
}
viewHolder.preText.setText("Type your name");
return rowView;
}
Are you sure that Log.d() is not called? You may want to change logging scope, usually default scope is info and it doesn't show debug messages. You can try to use Log.i() or change scope.
Try posting your adapter.setNotifyOnChange(true); to handler. Follow this link