I'm trying to make a ToDo List App in Android. Here Is My code
MainActivity.java
import com.vrishankgupta.adapter.myPkg.listClass;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
ArrayList<listClass> arr = new ArrayList<listClass>(0);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
arr.add(new listClass("Task 1",false));
arr.add(new listClass("Task 2",true));
arr.add(new listClass("Task 3",true));
arr.add(new listClass("Task 4",false));
final CustomAdapter adapter = new CustomAdapter(this,arr);
final ListView lv = findViewById(R.id.vishulv);
Log.e("Task 1", arr.get(0).isActive()+"" );
lv.setAdapter(adapter);
final EditText etnew = findViewById(R.id.etNew);
Button add = findViewById(R.id.addButn);
add.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(etnew.getText()==null || etnew.getText().toString().equals(""))
{
Toast.makeText(getApplicationContext(),"Enter data",Toast.LENGTH_LONG).show();
}
else
{
arr.add(new listClass(etnew.getText().toString(),false));
CustomAdapter adapter = new CustomAdapter(MainActivity.this,arr);
final ListView lv = findViewById(R.id.vishulv);
lv.setAdapter(adapter);
etnew.setText("");
}
}
});
}
}
CustomAdapter
package com.vrishankgupta.adapter;
public class CustomAdapter extends ArrayAdapter<listClass> {
ArrayList<listClass> arr;
public CustomAdapter(#NonNull Context context, ArrayList<listClass> arr) {
super(context,R.layout.detail, arr);
this.arr = new ArrayList<listClass>(0);
this.arr.addAll(arr);
}
#NonNull
#Override
public View getView(final int position, #Nullable View convertView, #NonNull final ViewGroup parent) {
final ViewHolder holder;
if(convertView == null)
{
holder = new ViewHolder();
convertView = LayoutInflater.from(getContext()).inflate(R.layout.detail,parent,false);
holder.textview = (TextView)convertView.findViewById(R.id.todoTaskTV);
holder.checkBox = (CheckBox)convertView.findViewById(R.id.checkBut);
holder.button = (Button)convertView.findViewById(R.id.delBut);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder)convertView.getTag();
}
listClass task = arr.get(position);
Log.e("Checking", position + task.getTask().toString() );
holder.textview.setText(task.getTask());
holder.checkBox.setChecked(task.isActive());
holder.checkBox.setTag(task);
holder.button.setTag(task);
notifyDataSetChanged();
holder.checkBox.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
CheckBox cb = (CheckBox)v;
listClass task = (listClass) cb.getTag();
Toast.makeText(getContext(),"Checkbox",Toast.LENGTH_LONG).show();
task.setActive(cb.isChecked());
Log.e("isActive Task1", arr.get(1).isActive() +"" );
}
});
holder.button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Button im = (Button) v;
listClass task = (listClass) im.getTag(R.id.delBut);
arr.remove(task);
Log.e("Del but",position + "");
Toast.makeText(getContext(),"Del",Toast.LENGTH_LONG).show();
}
});
Log.e("isActive Task1", arr.get(1).isActive() +"" );
return convertView;
}
}
ViewHolder Class
public class ViewHolder {
TextView textview;
Button button;
CheckBox checkBox;
}
listClass
public class listClass {
String task;
boolean active;
public listClass(String task, boolean active) {
this.task = task;
this.active = active;
}
public String getTask() {
return task;
}
public void setTask(String task) {
this.task = task;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.vrishankgupta.adapter.MainActivity">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter New Task"
android:id="#+id/etNew"
android:textSize="24sp"
android:layout_gravity="left"
android:gravity="left"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="ADD"
android:id="#+id/addButn"
android:textSize="24sp"/>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/vishulv"
android:layout_marginTop="94dp"
/>
</FrameLayout>
detail.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="left"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="#+id/todoTaskTV"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:paddingLeft="8dp"
android:textSize="18sp"
android:textStyle="bold" />
<Button
android:id="#+id/delBut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="Delete"
android:layout_marginRight="5dp"
/>
<CheckBox
android:id="#+id/checkBut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/delBut"
android:layout_centerVertical="true"
android:layout_marginRight="10dp" />
</RelativeLayout>
I want to remove List element on Click of Delete Button or toggle the status of task with checkBox,I'm not even seeing the Toast that is present in clickListener of Checkbox and Delete Button,there's just nothing happening, unable to figure out how to do that..
Make a Callback interface to solve your problem. I think this the best way what you want to achieve.
OnItemClickListener
public class OnItemClickListener implements View.OnClickListener {
private int position;
private OnItemClickCallback onItemClickCallback;
public OnItemClickListener(int position, OnItemClickCallback
onItemClickCallback) {
this.position = position;
this.onItemClickCallback = onItemClickCallback;
}
#Override
public void onClick(View view) {
onItemClickCallback.onItemClicked(view, position);
}
public interface OnItemClickCallback {
void onItemClicked(View view, int position);
}
}
In your adapter class
private OnItemClickListener.OnItemClickCallback onItemClickCallback;
public CustomAdapter(#NonNull Context context, ArrayList<listClass> arr,
OnItemClickListener.OnItemClickCallback onItemClickCallback)
{
super(context,R.layout.detail, arr);
this.arr = new ArrayList<listClass>(0);
this.onItemClickCallback = onItemClickCallback;
this.arr.addAll(arr);
}
and
holder.imageButton.setOnClickListener(new OnItemClickListener(position,
onItemClickCallback));
In your activity
private OnItemClickListener.OnItemClickCallback
onItemDeleteClickCallback = new
OnItemClickListener.OnItemClickCallback() {
#Override
public void onItemClicked(View view, int position) {
//here you will get delete item pos
}
};
and
CustomAdapter adapter = new CustomAdapter(MainActivity.this, arr,
onItemDeleteClickCallback );
final ListView lv = findViewById(R.id.vishulv);
lv.setAdapter(adapter);
Hope this will help you.
Try this in your adapter
holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.isChecked()) {
//checked
Toast.makeText(getContext(),"active checkbox",Toast.LENGTH_LONG).show();
}
else
{
//not checked
Toast.makeText(getContext(),"inactive checkbox",Toast.LENGTH_LONG).show();
}
});
Related
My code java. I'm getting data from the intent as an array. I am using arraylist,listview and custom adapter. I can show the incoming data using listview. I want the item I clicked to be deleted. The name of my delete button "deleteshop" in customadapter. How can I do that ?
My code;
final ListView list = findViewById(R.id.list);
final ArrayList<SubjectData> arrayList = new ArrayList<SubjectData>();
final String[] cartList = getIntent().getStringArrayExtra("saleData");
arrayList.add(new SubjectData("", ""));
final int cartListLength = cartList.length;
int counter = 0;
String lastItem = "";
for (String e : cartList) {
counter += 1;
if (e == "" || e == null) {
lastItem = cartList[counter-3];
break;
}
String productPhoto = "";
switch (e) {
case "1 PC GREEN COLA x 10.00 TL":
productPhoto = "cc";
break;
default:
productPhoto = "";
break; }
arrayList.add(new SubjectData(e, productPhoto));;
}
arrayList.remove(arrayList.size()-1);
arrayList.remove(arrayList.size()-1);
arrayList.add(new SubjectData("*** GRAND TOTAL TL:" + lastItem + " ***", "arrowgreen"));
arrayList.add(new SubjectData("", ""));
arrayList.add(new SubjectData("", ""));
final CustomAdapter customAdapter = new CustomAdapter(this, arrayList);
list.setAdapter(customAdapter);
SubjectData model class:
String SubjectName;
String Image;
public SubjectData(String subjectName, String image) {
this.SubjectName = subjectName;
this.Image = image;
}
Customadapter;
class CustomAdapter implements ListAdapter {
ArrayList<SubjectData> arrayList;
Context context;
public CustomAdapter(Context context, ArrayList<SubjectData> arrayList) {
this.arrayList=arrayList;
this.context=context;
}
#Override
public boolean areAllItemsEnabled() {
return false;
}
#Override
public boolean isEnabled(int position) {
return true;
}
#Override
public void registerDataSetObserver(DataSetObserver observer) {
}
#Override
public void unregisterDataSetObserver(DataSetObserver observer) {
}
#Override
public int getCount() {
return arrayList.size();
}
#Override
public Object getItem(int position) {
return position;
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public boolean hasStableIds() {
return false;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
final SubjectData subjectData=arrayList.get(position);
if(convertView==null){
LayoutInflater layoutInflater = LayoutInflater.from(context);
convertView=layoutInflater.inflate(R.layout.list_row, null);
TextView tittle=convertView.findViewById(R.id.title);
ImageView imag=convertView.findViewById(R.id.list_image);
ImageView
deleteshop=convertView.findViewById(R.id.deleteshop);
deleteshop.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Toast.makeText(context, "Deneme",
Toast.LENGTH_SHORT).show();
}
});
tittle.setText(subjectData.SubjectName);
Resources resources = context.getResources();
final int resourceId = resources.getIdentifier(subjectData.Image, "drawable",
context.getPackageName());
imag.setImageResource(resourceId);
}
return convertView;
}
#Override
public int getItemViewType(int position) {
return position;
}
#Override
public int getViewTypeCount() {
return arrayList.size();
}
#Override
public boolean isEmpty() {
return false;
}
listview design;
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip">
<LinearLayout
android:id="#+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:padding="3dip">
<ImageView
android:id="#+id/list_image"
android:layout_width="50dip"
android:layout_height="50dip" />
</LinearLayout>
<TextView
android:id="#+id/title"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_alignTop="#+id/thumbnail"
android:layout_toRightOf="#+id/thumbnail"
android:gravity="center"
android:textColor="#040404"
android:textSize="15dip"
android:textStyle="bold"
android:typeface="sans" />
<ImageView
android:layout_gravity="center"
android:id="#+id/deleteshop"
android:src="#drawable/negative"
android:layout_width="25dp"
android:layout_height="25dp" ></ImageView>
</LinearLayout>
If you want to delete clicked item from your list view then you can use this code .I tested and its deleting smoothly , after deleting its updating list also.
CustomAdapter customAdapter = new CustomAdapter(this,R.layout.list_row, arrayList);
list.setAdapter(customAdapter);
// after setting adapter put this code
// and update your ui again using set adapter
Log.e("Custom",""+arrayList.size());
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
arrayList.remove(i);
list.setAdapter(customAdapter);
}
});
This is not a best solution but ulternative , suppose if you want to update your adapter on click of deletebutton first create one interface , here is sample
public interface MyInterface{
public void deleteItem(int pos);
}
Now in your main activity use like this MainActivity extends AppCompatActivity implements MyInterface and place your interface method public void deleteItem(int pos){ arrayList.remove(pos); list.setAdapter(customAdapter); }
After that call this method from your adapter like below
deleteshop.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Toast.makeText(context, "Delete",
Toast.LENGTH_SHORT).show();
//Actually change your list of items here
if (context instanceof SampleList) {
((MainActivity)context).deleteItem(position);
}
}
});
I am currently working with Android and UltimateRecycleView. I manage to make the ultimaterecycleview working, but when I tried to use the load more functionality, the bottom progress bar is not showing (although the data is loaded). Anyone has experienced this problem? Can you please help me to find out what is wrong?
Here is the code :
--- Adapter ---
public class ListPendingAdapter extends UltimateViewAdapter<ListPendingAdapter.PendingViewHolder> {
private Context context;
private List<Queue> queues;
public ListPendingAdapter(Context context, List<Queue> queues) {
this.context = context;
this.queues = queues;
}
#Override
public PendingViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.pending_list, parent, false);
PendingViewHolder vh = new PendingViewHolder(v);
return vh;
}
#Override
public void onBindViewHolder(PendingViewHolder holder, int position) {
TextView nodata = (TextView) ((Activity) context).findViewById(R.id.nodata);
if(queues.size() <= 0){
nodata.setVisibility(View.VISIBLE);
} else {
nodata.setVisibility(View.GONE);
User user = new User(queues.get(position).getQueuer());
if (user.getProfilePicture() == null) {
holder.photo.setImageDrawable(context.getResources().getDrawable(R.drawable.default_photo));
} else {
ImageUtil.setParseFileImageToView(context, user.getProfilePicture(), holder.photo);
}
holder.name.setText(user.getFullname());
holder.totalPerson.setText(Integer.toString(queues.get(position).getTotalPax()));
holder.timeQueue.setText(DateUtil.formatDateIntoTimeString(queues.get(position).getCreatedAt()));
attachButtonClickListener(holder.accept, true, position, holder.parent);
attachButtonClickListener(holder.reject, false, position, holder.parent);
CustomerUtil.attachUsernameListener((Activity) context, holder.name, queues.get(position));
CustomerUtil.attachProfpicListener((Activity) context, holder.photo, queues.get(position));
}
}
#Override
public int getItemCount() {
int size = (queues == null ? 0 : queues.size());
return size;
}
#Override
public PendingViewHolder onCreateViewHolder(ViewGroup viewGroup) {
View v = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.pending_list, viewGroup, false);
PendingViewHolder vh = new PendingViewHolder(v);
return vh;
}
#Override
public PendingViewHolder getViewHolder(View view) {
return new PendingViewHolder(view);
}
#Override
public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup viewGroup) {
View view = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.custom_bottom_progressbar, viewGroup, false);
return new RecyclerView.ViewHolder(view) {
};
}
#Override
public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
}
#Override
public long generateHeaderId(int position) {
if (getItem(position).get("objectId").toString().length() > 0)
return (getItem(position).get("objectId").toString()).charAt(0);
else return -1;
}
#Override
public int getAdapterItemCount() {
int size = (queues == null ? 0 : queues.size());
return size;
}
public Queue getItem(int position) {
if (customHeaderView != null)
position--;
if (position < queues.size())
return queues.get(position);
else return null;
}
private void attachButtonClickListener(Button button, final boolean isAccept, final int position, final View parent){
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
callPendingProcess(isAccept, position, parent);
}
});
}
private void callPendingProcess(final boolean isAccept, final int position, final View parent){
ProcessPending processPending = new ProcessPending(context, this, isAccept, position, parent);
processPending.execute();
}
public List<Queue> getDataset(){
return queues;
}
public static class PendingViewHolder extends UltimateRecyclerviewViewHolder {
public CircleImageView photo;
public TextView name;
public TextView totalPerson;
public TextView timeQueue;
public Button accept;
public Button reject;
public View parent;
public PendingViewHolder(View v) {
super(v);
parent = v;
photo = (CircleImageView) v.findViewById(R.id.photo);
name = (TextView) v.findViewById(R.id.cust_name);
totalPerson = (TextView) v.findViewById(R.id.total_cust);
timeQueue = (TextView) v.findViewById(R.id.time_queue);
accept = (Button) v.findViewById(R.id.accept_btn);
reject = (Button) v.findViewById(R.id.reject_btn);
}
}
}
--- Async Task (where I set the adapter to listview) ---
public class LoadPendingCustomer extends AsyncTask<Void, Void, List<Queue>> {
private Context context;
private Activity activity;
private ProgressBar pb;
private View view;
private View layout;
private int skipCount;
private boolean isLoadMore;
public LoadPendingCustomer(Context context, View layout, int skipCount, boolean isLoadMore) {
this.context = context;
this.activity = (Activity) context;
this.layout = layout;
this.skipCount = skipCount;
this.isLoadMore = isLoadMore;
this.pb = (ProgressBar) layout.findViewById(R.id.pending_progress);
this.view = layout.findViewById(R.id.pending_list_container);
}
#Override
protected void onPreExecute() {
if(!isLoadMore) {
ProgressUtil.showProgress(true, view, pb, context);
}
}
#Override
protected List<Queue> doInBackground(Void... arg0) {
List<Queue> queues = null;
try {
List<String> statuses = new ArrayList<String>();
statuses.add(Queue.STATUS_PENDING_APPROVAL);
queues = QueueDao.getCustomersBasedOnStatus(statuses, skipCount);
} catch (ParseException e) {
Log.w(MainActivity.TAG, "Error while retrieving pending queues", e);
}
return queues;
}
#Override
protected void onPostExecute(List<Queue> results) {
TextView nodata = (TextView) layout.findViewById(R.id.nodata);
if(results == null){
nodata.setVisibility(View.VISIBLE);
} else {
if (results.size() <= 0) {
if(!isLoadMore) {
nodata.setVisibility(View.VISIBLE);
}
} else {
nodata.setVisibility(View.GONE);
UltimateRecyclerView queueList = (UltimateRecyclerView) layout.findViewById(R.id.pendinglist);
if(!isLoadMore || queueList.getAdapter() == null){
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(activity);
ListPendingAdapter listPendingAdapter = new ListPendingAdapter(context, results);
queueList.setLayoutManager(layoutManager);
queueList.setAdapter(listPendingAdapter);
} else {
ListPendingAdapter listPendingAdapter = (ListPendingAdapter) queueList.getAdapter();
listPendingAdapter.getDataset().addAll(results);
listPendingAdapter.notifyDataSetChanged();
}
setLoadMore(queueList);
}
}
if(!isLoadMore) {
ProgressUtil.showProgress(false, view, pb, context);
}
}
private void setLoadMore(final UltimateRecyclerView queueList){
queueList.reenableLoadmore();
queueList.setLoadMoreView(R.layout.custom_bottom_progressbar);
queueList.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {
#Override
public void loadMore(int i, int i1) {
LoadPendingCustomer loadPendingCustomer = new LoadPendingCustomer(context, layout, skipCount + 10, true);
loadPendingCustomer.execute();
}
});
}
}
--- fragment xml ---
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/activity_vertical_margin"
android:layout_marginLeft="#dimen/activity_horizontal_margin"
android:layout_marginRight="#dimen/activity_horizontal_margin"
tools:context=".fragments.QueueFragment">
<!-- TODO: Update blank fragment layout -->
<ProgressBar
android:id="#+id/pending_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:visibility="gone" />
<LinearLayout
android:id="#+id/pending_list_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/nodata"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="#string/nodata"
android:visibility="gone"/>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/pending_swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.marshalchen.ultimaterecyclerview.UltimateRecyclerView
android:id="#+id/pendinglist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"/>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
</RelativeLayout>
--- custom_bottom_progressbar.xml ---
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/bottomPB"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffff">
<ProgressBar
android:layout_width="30dp"
android:layout_height="30dp"
android:id="#+id/bottom_progress_bar"
android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/loading"
android:layout_below="#+id/bottom_progress_bar"
android:layout_marginTop="2dp"
android:gravity="center"/>
</RelativeLayout>
Please help me. Thanks in advance...
I've made a custom adapter for a ListView in order to display a String and an ImageButton within the same row. A row is generated every time the add button is clicked. The string is taken from the EditText field, while the ImageButton bin_button is allocated dinamically. Everything works fine except I can't make the bin_buttons fire an OnClick event.
I've tried several solutions. Here bin_button_listener is generated outside the add_button OnClickListener and then set. I've also tried to set listeners with a new OnClickListener every time a new bin_button was created.
Here some code:
Row layout list_string_button_layout.xml:
<TextView
android:id="#+id/list_item_string"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingEnd="0dp"
android:paddingTop="8dp"
android:textSize="18sp"
android:textStyle="bold"/>
<ImageButton
android:id="#+id/delete_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingEnd="5dp"
android:background="#00ffffff"
android:src="#drawable/ic_delete_black_18dp"
android:layout_alignBottom="#+id/list_item_string"
android:layout_alignParentEnd="true"
android:focusableInTouchMode="true"
/>
</RelativeLayout>
Activity layout activity_search.xml:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ingredient_text_input"
android:hint="#string/start_typing_ingredient"
android:layout_marginTop="52dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
/>
<Button
style="#style/Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/add_button"
android:backgroundTint="#color/colorPrimaryLight"
android:id="#+id/add_button"
android:layout_alignTop="#+id/ingredient_text_input"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ingredients_view"
android:layout_above="#+id/search_button"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/add_button" />
</RelativeLayout>
Custom Adapter IngredientBinAdapter:
public class IngredientBinAdapter extends BaseAdapter {
private Context context = null;
private List<HashMap<String,ImageButton>> items = new ArrayList<>();
public IngredientBinAdapter(Context context, ArrayList<HashMap<String,ImageButton>> items){
this.context=context;
this.items=items;
}
#Override
public int getCount() {
return items.size();
}
#Override
public Object getItem(int position) {
return items.get(position);
}
#Override
public long getItemId(int position) {
return getItem(position).hashCode();
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null)
convertView = LayoutInflater.from(context).inflate(R.layout.list_string_button_layout,null);
HashMap<String,ImageButton> item = (HashMap<String,ImageButton>) getItem(position);
TextView string = (TextView) convertView.findViewById(R.id.list_item_string);
String key=(String) item.keySet().toArray()[0];
string.setText(key);
item.get(key).setImageResource(R.drawable.ic_delete_black_18dp);
return convertView;
}
}
Activity:
public class SearchActivity extends AppCompatActivity{
//getting resources and allocating variables
Button add_button = null;
Button search_button = null;
EditText insert_ingredient = null;
ListView ingredient_list_view = null;
ArrayList<HashMap<String,ImageButton>> ingredient_list = new ArrayList<>();
IngredientBinAdapter list_adapter = new IngredientBinAdapter(this,ingredient_list);
ArrayList<String> ingredients_utils = new ArrayList<>();
View.OnClickListener bin_button_listener = new View.OnClickListener() {
#Override
public void onClick(View v) {
System.out.println("BIN_BUTTON CLICKED");
ImageButton clicked_button = (ImageButton) v;
for(Iterator<HashMap<String,ImageButton>> i = ingredient_list.iterator(); i.hasNext(); ){
HashMap<String,ImageButton> temp= i.next();
if(temp.values().toArray()[0].equals(clicked_button))
ingredient_list.remove(temp);
}
list_adapter.notifyDataSetChanged();
}
};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
}
#Override
protected void onStart(){
super.onStart();
add_button = (Button) findViewById(R.id.add_button);
search_button = (Button) findViewById(R.id.search_button2);
insert_ingredient = (EditText) findViewById(R.id.ingredient_text_input);
ingredient_list_view = (ListView) findViewById(R.id.ingredients_view);
ingredient_list_view.setAdapter(list_adapter);
//add_button listener
add_button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String current_ingredient_string = insert_ingredient.getText().toString().trim();
if (!current_ingredient_string.isEmpty() && !ingredients_utils.contains(current_ingredient_string)) {
HashMap<String, ImageButton> temp = new HashMap<String, ImageButton>();
ImageButton temp_bin_button = new ImageButton(SearchActivity.this);
temp_bin_button.setOnClickListener(bin_button_listener);
temp.put(current_ingredient_string, temp_bin_button);
ingredient_list.add(temp);
list_adapter.notifyDataSetChanged();
}
ingredients_utils.add(insert_ingredient.getText().toString().trim());
insert_ingredient.getText().clear();
}
});
}
}
first of all
u should move your logic to onCreate() see: Difference between onCreate() and onStart()?
second
u should in your method in adapter :
#Override
public View getView(int position, View convertView, ViewGroup parent) {
// 1. inflate view
// 2. find button
// 3. assign here listener to bin button
// i advice to use convert view pattern
}
some hints :
create data object describing row item
public class BinRow {
private String _someString;
private Drawable _imageDrawable; // (or resource id name)
public String getString() {
return _someString;
}
public Drawable getImage() {
return _imageDrawable;
}
public BinRow(String someText, Drawable imageDrawable) {
_someText = someText;
_imageDrawable = imageDrawable;
}
}
here u have adapter example ( u need adjust Album - to your BinRow & layout for row & convert view items in view holder ) - this should show you idea how adapter works :
public class AlbumAdapter extends BaseAdapter implements IListAdapter<Album> {
private List<Album> _albums;
private Context _context;
private LayoutInflater _layoutInflater;
static class ViewHolder {
ImageView imageView;
TextView albumName;
public ViewHolder(View v) {
imageView = (ImageView) v.findViewById(R.id.image);
albumName = (TextView) v.findViewById(R.id.tvAlbumName);
}
}
public AlbumAdapter(List<Album> albums) {
if(albums == null) {
_albums = new ArrasyList<>();
} else {
_albums = albums;
}
}
#Override
public int getCount() {
return _albums.size();
}
#Override
public Album getItem(int position) {
return _albums.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, final ViewGroup parent) {
final Album album = getItem(position);
if (_context == null) {
_context = parent.getContext();
}
if (_layoutInflater == null) {
_layoutInflater = LayoutInflater.from(_context);
}
View _view = convertView;
ViewHolder viewHolder;
if (_view == null) {
_view = _layoutInflater.inflate(R.layout.album_item_layout, parent, false);
viewHolder = new ViewHolder(_view);
_view.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) _view.getTag();
}
viewHolder.albumName.setText(album.getAlbumDescription());
// here u can set: image to image view & listener to image
// image view could be a button
viewHolder.imageView.setOnClickListener(View.OnClickListener);
return _view;
}
#Override
public void add(Album listElement) {
_albums.add(listElement);
}
#Override
public void addAll(List<Album> listOfElements) {
_albums.addAll(listOfElements);
}
#Override
public void clear() {
_albums.clear();
}
#Override
public void remove(Album listElement) {
_albums.remove(listElement);
}
}
public interface IListAdapter<T> {
void add(T listElement);
void addAll(List<T> listOfElements);
void clear();
void remove(T listElement);
}
above interface serves as helper for adapter list methods
in my listview already 20 items and above listview there is one "ADD" button .when i am click on button then open one popup dialog.. in popup dialog there is on edittext and save and close button .. when i am write something edittext and click on save button then its not working.... i'll use custom listview with one image left side and text in center..... help me
Button add = (Button)findViewById(R.id.btn_Add);
add.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.popup);
dialog.setTitle("Add Category");
Button close = (Button)dialog.findViewById(R.id.btn_cls);
close.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
dialog.dismiss();
}
});
Button save = (Button)dialog.findViewById(R.id.btn_sv);
save.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
EditText edit = (EditText)dialog.findViewById(R.id.editText1);
list.add(edit.getText().toString());
edit.setText("");
adapter.notifyDataSetChanged();
}
});
dialog.show();
}
});
Try this way,hope this will help you to solve your problem.
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="#drawable/black"
android:orientation="vertical">
<EditText
android:id="#+id/search"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#drawable/bbbb"
android:ems="10"
android:textColor="#color/White"
android:hint="Search"
android:padding="5dp"
android:textSize="20sp">
<requestFocus />
</EditText>
<ListView
android:id="#+id/listview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="10dp"
android:dividerHeight="5dp"
android:cacheColorHint="#null"
android:listSelector="#null"
android:clipToPadding="false"
android:drawSelectorOnTop="true" />
<Button
android:id="#+id/btn_Add"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#drawable/list_selector"
android:text="ADD Category"
android:textSize="25sp"
android:textStyle="bold" />
</LinearLayout>
listview_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/button_border"
android:gravity="center"
android:padding="5dp">
<ImageView
android:id="#+id/flag"
android:background="#drawable/sd"
android:layout_width="60dp"
android:layout_height="60dp"
android:adjustViewBounds="true"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="5dp">
<TextView
android:id="#+id/country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="21sp"
android:textStyle="bold" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/round"
android:layout_marginLeft="5dp"/>
</LinearLayout>
popup.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<Button
android:id="#+id/btn_cls"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#drawable/list_selector"
android:text="Close" />
<Button
android:id="#+id/btn_sv"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="#drawable/list_selector"
android:text="Save" />
</LinearLayout>
</LinearLayout>
MainActivity.java
public class MainActivity extends Activity {
private ListView list;
private ListViewAdapter adapter;
private EditText editsearch;
private Button add;
private String[] animal = new String[] {"COW","LION","TIGER","ELEPHANT","MONKEY","DONKEY"};
private ArrayList<String> listData;
private Dialog dialog;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
list = (ListView) findViewById(R.id.listview);
add = (Button)findViewById(R.id.btn_Add);
listData = new ArrayList<String>();
for (int i=0;i<animal.length;i++){
listData.add(animal[i]);
}
Collections.sort(listData);
add.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
addAnimal();
}
});
adapter = new ListViewAdapter(this,listData);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(MainActivity.this,listData.get(position),Toast.LENGTH_SHORT).show();
// if(listData.get(position).equals("COW"));
// intent = new Intent(getBaseContext(),COW.class);
//
// else if(listData.get(position).equals("LION"))
// intent = new Intent(getBaseContext(),LION.class);
//
// else if(listData.get(position).equals("TIGER"))
// intent = new Intent(getBaseContext(),TIGER.class);
//
// else if(listData.get(position).equals("MONKEY"))
// intent = new Intent(getBaseContext(),MOKEY.class);
//
// else if(listData.get(position).equals("DONKEY"))
// intent = new Intent(getBaseContext(),DONKEY.class);
}
});
editsearch = (EditText) findViewById(R.id.search);
editsearch.addTextChangedListener(new TextWatcher() {
#Override
public void afterTextChanged(Editable arg0) {
String text = editsearch.getText().toString();
adapter.filter(text);
}
#Override
public void beforeTextChanged(CharSequence arg0, int arg1,
int arg2, int arg3) {
}
#Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2,int arg3) {
}
});
}
public void addAnimal(){
dialog = new Dialog(this);
dialog.setContentView(R.layout.popup);
dialog.setTitle("Add Animal");
final EditText edit = (EditText)dialog.findViewById(R.id.editText1);
Button close = (Button)dialog.findViewById(R.id.btn_cls);
close.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
dialog.dismiss();
}
});
Button save = (Button)dialog.findViewById(R.id.btn_sv);
save.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
if(edit.getText().toString().trim().length()>0){
listData.add(edit.getText().toString());
Collections.sort(listData);
adapter = new ListViewAdapter(MainActivity.this,listData);
list.setAdapter(adapter);
dialog.dismiss();
}else{
edit.setError("Value Required");
}
}
});
dialog.show();
}
class ListViewAdapter extends BaseAdapter {
private Context context;
private ArrayList<String> data;
private ArrayList<String> filterData;
public ListViewAdapter(Context context,ArrayList<String> data) {
this.context = context;
this.data = data;
filterData =new ArrayList<String>();
filterData.addAll(this.data);
}
public class ViewHolder {
TextView country;
}
#Override
public int getCount() {
return filterData.size();
}
#Override
public Object getItem(int position) {
return filterData.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
public View getView(final int position, View view, ViewGroup parent) {
final ViewHolder holder;
if (view == null) {
holder = new ViewHolder();
view = LayoutInflater.from(context).inflate(R.layout.listview_item, null);
holder.country = (TextView) view.findViewById(R.id.country);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
holder.country.setText(filterData.get(position));
return view;
}
public void filter(String charText) {
filterData.clear();
if (charText.length() == 0) {
filterData.addAll(data);
}else{
for (String animal : data){
if (animal.toLowerCase().contains(charText.toLowerCase())){
filterData.add(animal);
}
}
}
notifyDataSetChanged();
}
}
}
i will use like that..
public class list extends Activity {
private ListView list;
private Button add ;
private Dialog dialog;
private ListViewAdapter adapter;
private ArrayList<String> listData;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_item);
list = (ListView)findViewById(R.id.listview1);
add = (Button)findViewById(R.id.btn_Addd);
listData = new ArrayList<String>();
add.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
AddSMS();
}
});
list.setAdapter(adapter);
}
public void AddSMS(){
dialog = new Dialog(this);
dialog.setContentView(R.layout.popup1);
dialog.setTitle("Add Your SMS");
final EditText et = (EditText)dialog.findViewById(R.id.editText11);
Button close = (Button)dialog.findViewById(R.id.btn_clss);
close.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
dialog.dismiss();
}
});
Button save = (Button)dialog.findViewById(R.id.btn_svv);
save.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
if (et.getText().toString().trim().length()>0){
listData.add(et.getText().toString());
adapter = new ListViewAdapter(list.this, listData);
list.setAdapter(adapter);
dialog.dismiss();
}else {
et.setError("Value Required");
}
}
});
dialog.show();
}
class ListViewAdapter extends BaseAdapter {
private Context context;
private ArrayList<String> data;
private ArrayList<String> filterData;
public ListViewAdapter(Context context,ArrayList<String> data) {
this.context = context;
this.data = data;
filterData =new ArrayList<String>();
filterData.addAll(this.data);
}
public class ViewHolder {
TextView txttt;
}
#Override
public int getCount() {
return filterData.size();
}
#Override
public Object getItem(int position) {
return filterData.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
public View getView(final int position, View view, ViewGroup parent) {
final ViewHolder holder;
if (view == null) {
holder = new ViewHolder();
view = LayoutInflater.from(context).inflate(R.layout.list_double, null);
holder.txttt = (TextView) view.findViewById(R.id.txttt);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
holder.txttt.setText(filterData.get(position));
return view;
}
public void filter(String charText) {
filterData.clear();
if (charText.length() == 0) {
filterData.addAll(data);
}else{
for (String Detail : data){
if (Detail.toLowerCase().contains(charText.toLowerCase())){
filterData.add(Detail);
}
}
}
notifyDataSetChanged();
}
}
}
instead of add to list add the item in adapter and then call notifyDataSetChanged
public class MainActivity extends Activity {
Button okButton;
EditText wishEditText;
ListView wishListView;
BaseAdapter adapter;
ArrayList<list_item>arrayList;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 0);
setContentView(R.layout.activity_main);
initializedAll();
}
public void initializedAll() {
okButton = (Button) findViewById(R.id.button1);
wishEditText = (EditText) findViewById(R.id.editText1);
wishListView = (ListView) findViewById(R.id.listView1);
arrayList = new ArrayList<list_item>();
adapter = new BaseAdapter() {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
#Override
public View getView(int position, View view, ViewGroup viewGroupgroup) {
if (view==null) {
view = inflater.inflate(R.layout.wish_list_item, null);
}
TextView wishText = (TextView) findViewById(R.id.wishItemtextView);
TextView dateText = (TextView) findViewById(R.id.wishDatetextView);
wishText.setText(arrayList.get(position).getWishString());
Date date = arrayList.get(position).getDate();
dateText.setText(DateFormat.format("dd/MM/yyyy HH:mm:ss a", date));
return view;
}
#Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
#Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return arrayList.get(position);
}
#Override
public int getCount() {
// TODO Auto-generated method stub
return arrayList.size();
}
};
wishListView.setAdapter(adapter);
okButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
String string = wishEditText.getText().toString();
Date date = new Date();
list_item item = new list_item(date,string);
arrayList.add(item);
adapter.notifyDataSetChanged();
wishEditText.setText("");
InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(wishEditText.getWindowToken(), 0);
Toast.makeText(getBaseContext(), "New wish Added To List", Toast.LENGTH_SHORT);
}
});
};
}
Please help me.
When I pressed OK button then my apps has stop but there is no error even eclipse do't show any error.
How I can solve it?
Please help me.
This like inputMethodManager.hideSoftInputFromWindow(wishEditText.getWindowToken(), 0); might be giving you a NullPointerException
Try this way,hope this will help you to solve your problem.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp">
<EditText
android:id="#+id/edtWishText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:id="#+id/btnAddWishText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="Add"/>
</LinearLayout>
<ListView
android:id="#+id/lstWish"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:divider="#android:color/white"
android:dividerHeight="1dp"/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:id="#+id/txtWishText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/txtWishDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"/>
</LinearLayout>
public class MainActivity extends Activity{
private ListView lstWish;
private EditText edtWishText;
private Button btnAddWishText;
private WishListAdapter listAdapter;
private ArrayList<HashMap<String,Object>> wishList;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 0);
setContentView(R.layout.activity_main);
lstWish = (ListView) findViewById(R.id.lstWish);
edtWishText = (EditText) findViewById(R.id.edtWishText);
btnAddWishText = (Button) findViewById(R.id.btnAddWishText);
wishList =new ArrayList<HashMap<String, Object>>();
listAdapter = new WishListAdapter(this,wishList);
lstWish.setAdapter(listAdapter);
btnAddWishText.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if(edtWishText.getText() == null && edtWishText.getText().toString().length()<=0){
edtWishText.setError("Value required");
}else{
HashMap<String,Object> data = new HashMap<String, Object>();
data.put("WishText",edtWishText.getText().toString());
data.put("WishText",new Date());
wishList.add(data);
listAdapter.notifyDataSetChanged();
edtWishText.setText("");
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(edtWishText.getWindowToken(), 0);
Toast.makeText(getBaseContext(), "New wish Added To List", Toast.LENGTH_SHORT).show();
}
}
});
}
class WishListAdapter extends BaseAdapter{
private Context mContext;
public ArrayList<HashMap<String,Object>> wishList;
public WishListAdapter(Context mContext,ArrayList<HashMap<String,Object>> wishList)
{
this.mContext = mContext;
this.wishList = wishList;
}
#Override
public int getCount(){
return wishList.size();
}
#Override
public Object getItem(int position)
{
return wishList.get(position);
}
#Override
public long getItemId(int position)
{
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if(convertView==null){
holder = new ViewHolder();
convertView = LayoutInflater.from(mContext).inflate(R.layout.list_item,null,false);
holder.txtWishText = (TextView) convertView.findViewById(R.id.txtWishText);
holder.txtWishDate = (TextView) convertView.findViewById(R.id.txtWishDate);
convertView.setTag(holder);
}else{
holder = (ViewHolder)convertView.getTag();
}
holder.txtWishText.setText(wishList.get(position).get("wishText").toString());
holder.txtWishDate.setText(DateFormat.format("dd/MM/yyyy HH:mm:ss a",(Date)wishList.get(position).get("WishDate")));
return convertView;
}
}
public static class ViewHolder
{
public TextView txtWishText;
public TextView txtWishDate;
}
}