Created
April 16, 2019 11:15
-
-
Save walteranyika/fb3777043b8bde52c52fcd8c10f07f54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.BaseAdapter; | |
import android.widget.ImageView; | |
import android.widget.TextView; | |
import java.util.ArrayList; | |
/** | |
* Created by walter on 3/10/19. | |
*/ | |
public class SimpleAdapter extends BaseAdapter { | |
Context mContext; | |
ArrayList<Item> mArrayList; | |
public SimpleAdapter(Context mContext, ArrayList<Item> mArrayList) { | |
this.mContext = mContext; | |
this.mArrayList = mArrayList; | |
} | |
@Override | |
public int getCount() { | |
return mArrayList.size(); | |
} | |
@Override | |
public Object getItem(int i) { | |
return mArrayList.get(i); | |
} | |
@Override | |
public long getItemId(int i) { | |
return i; | |
} | |
@Override | |
public View getView(int i, View view, ViewGroup viewGroup) { | |
if (view == null) { | |
//MODIFY HERE | |
view = LayoutInflater.from(mContext).inflate(R.layout.list_item, null); | |
} | |
//MODIFY HERE | |
TextView txtName = view.findViewById(R.id.txtName); | |
TextView txtQuantity = view.findViewById(R.id.txtQuantity); | |
TextView txtPrice = view.findViewById(R.id.txtPrice); | |
Item order=mArrayList.get(i); | |
//MODIFY HERE | |
txtName.setText(order.getMeal()); | |
txtQuantity.setText(" x"+order.getQuantity()); | |
txtPrice.setText(order.getTotal()+""); | |
return view; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment