I am calling three JSONRequests with Volley and this method is called at every response of the request. This method only is executed when all three responses are ready. But when I try to update the expandable list it fails to display on the screen. Could anyone see if I am doing something wrong?
private void updateWhenReady(){
System.out.println(validCurrent+ " " + validDaily + " " + validHourly );
if(validCurrent && validDaily && validHourly)
{
System.out.println("in");
for (WeatherCondition wc: dailyResponseList)
{
ArrayList<WeatherCondition> tempList = new ArrayList<>();
for(WeatherCondition w: hourlyResponseList)
{
if(w.getDate().equalsIgnoreCase(wc.getDate()))
{
tempList.add(w);
}
}
weatherList.put(wc,tempList);
}
for (WeatherCondition weatherCondition: weatherList.keySet())
{
System.out.println(" + " + weatherCondition.getDate());
}
weatherList = dbHelper.getWeatherConditionsHashMap();
hourlyList = new ArrayList<WeatherCondition>(weatherList.keySet());
adapter = new WeatherSearchListAdapter(getActivity().getApplicationContext(), weatherList, hourlyList);
expList.setAdapter(adapter);
adapter.notifyDataSetChanged();
System.out.println(validCurrent + " " + validDaily + " " + validHourly);
validCurrent = false;
validDaily = false;
validHourly = false;
}
}
and the following is the explist adapter
public class WeatherSearchListAdapter extends BaseExpandableListAdapter {
private Context ctx;
private HashMap<WeatherCondition, List<WeatherCondition>> weatherList;
private List<WeatherCondition> list;
public WeatherSearchListAdapter(Context ctx, HashMap<WeatherCondition, List<WeatherCondition>> parentList, List<WeatherCondition> list){
this.weatherList = parentList;
this.list = list;
this.ctx = ctx;
};
#Override
public int getGroupCount() {
return list.size();
}
#Override
public int getChildrenCount(int groupPosition) {
return weatherList.get(list.get(groupPosition)).size();
}
#Override
public Object getGroup(int groupPosition) {
return list.get(groupPosition);
}
#Override
public Object getChild(int parent, int child) {
return weatherList.get(list.get(parent)).get(child);
}
#Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
#Override
public long getChildId(int parent, int child) {
return child;
}
#Override
public boolean hasStableIds() {
return false;
}
#Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
WeatherCondition groupWeatherCondition = (WeatherCondition) getGroup(groupPosition);
if(convertView == null)
{
LayoutInflater inflator = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflator.inflate(R.layout.fragment_daily_list_parent, parent, false);
}
ImageView weatherIconIdIV = (ImageView) convertView.findViewById(R.id.weatherIconIV);
ImageView windIconIdIV = (ImageView) convertView.findViewById(R.id.windDirectionIV);
TextView humidityTV = (TextView) convertView.findViewById(R.id.humitityListText);
TextView rainTV = (TextView) convertView.findViewById(R.id.rainListText);
TextView windDirectionTV = (TextView) convertView.findViewById(R.id.windDirectionText);
TextView windSpeedTV = (TextView) convertView.findViewById(R.id.windSpeedText);
TextView maxTempTV = (TextView) convertView.findViewById(R.id.maxTempListText);
TextView minTempTV = (TextView) convertView.findViewById(R.id.minTempListText);
TextView dateTV = (TextView) convertView.findViewById(R.id.dateListText);
String name = groupWeatherCondition.getWeatherIconId();
int weatherIconId = ctx.getResources().getIdentifier(name, "drawable", ctx.getPackageName());
weatherIconIdIV.setImageResource(weatherIconId);
String name1 = groupWeatherCondition.getWind().getWindIconId();
int windIconId = ctx.getResources().getIdentifier(name1, "drawable", ctx.getPackageName());
windIconIdIV.setImageResource(windIconId);
humidityTV.setText(groupWeatherCondition.getHumidity());
rainTV.setText(groupWeatherCondition.getRain());
windDirectionTV.setText(groupWeatherCondition.getWind().getWindDirection());
windSpeedTV.setText(groupWeatherCondition.getWind().getSpeed());
maxTempTV.setText(groupWeatherCondition.getMaxTemp());
minTempTV.setText(groupWeatherCondition.getMinTemp());
dateTV.setText(groupWeatherCondition.getDate());
convertView.setBackgroundColor(Color.parseColor("#5E5E5E"));
return convertView;
}
#Override
public View getChildView(int parent, int child, boolean isLastChild, View convertView, ViewGroup parentView) {
WeatherCondition childWeatherCondition = (WeatherCondition) getChild(parent, child);
if(convertView == null)
{
LayoutInflater inflator = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflator.inflate(R.layout.fragment_daily_list_parent, parentView, false);
}
ImageView weatherIconIdIV = (ImageView) convertView.findViewById(R.id.weatherIconIV);
ImageView windIconIdIV = (ImageView) convertView.findViewById(R.id.windDirectionIV);
TextView humidityTV = (TextView) convertView.findViewById(R.id.humitityListText);
TextView rainTV = (TextView) convertView.findViewById(R.id.rainListText);
TextView windDirectionTV = (TextView) convertView.findViewById(R.id.windDirectionText);
TextView windSpeedTV = (TextView) convertView.findViewById(R.id.windSpeedText);
TextView maxTempTV = (TextView) convertView.findViewById(R.id.maxTempListText);
TextView minTempTV = (TextView) convertView.findViewById(R.id.minTempListText);
TextView dateTV = (TextView) convertView.findViewById(R.id.dateListText);
String name = childWeatherCondition.getWeatherIconId();
int weatherIconId = ctx.getResources().getIdentifier(name, "drawable", ctx.getPackageName());
weatherIconIdIV.setImageResource(weatherIconId);
String name1 = childWeatherCondition.getWind().getWindIconId();
int windIconId = ctx.getResources().getIdentifier(name1, "drawable", ctx.getPackageName());
windIconIdIV.setImageResource(windIconId);
humidityTV.setText(childWeatherCondition.getHumidity());
rainTV.setText(childWeatherCondition.getRain());
windDirectionTV.setText(childWeatherCondition.getWind().getWindDirection());
windSpeedTV.setText(childWeatherCondition.getWind().getSpeed());
maxTempTV.setText(childWeatherCondition.getMaxTemp());
minTempTV.setText(childWeatherCondition.getMinTemp());
dateTV.setText(childWeatherCondition.getDate());
return convertView;
}
#Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
Do the variable initializations before the logic starts -
private void updateWhenReady(){
System.out.println(validCurrent+ " " + validDaily + " " + validHourly );
weatherList = dbHelper.getWeatherConditionsHashMap();
hourlyList = new ArrayList<WeatherCondition>(weatherList.keySet());
adapter = new WeatherSearchListAdapter(getActivity().getApplicationContext(), weatherList, hourlyList);
System.out.println(validCurrent + " " + validDaily + " " + validHourly);
if(validCurrent && validDaily && validHourly)
{
System.out.println("in");
for (WeatherCondition wc: dailyResponseList)
{
ArrayList<WeatherCondition> tempList = new ArrayList<>();
for(WeatherCondition w: hourlyResponseList)
{
if(w.getDate().equalsIgnoreCase(wc.getDate()))
{
tempList.add(w);
}
}
weatherList.put(wc,tempList);
}
for (WeatherCondition weatherCondition: weatherList.keySet())
{
System.out.println(" + " + weatherCondition.getDate());
}
//Do you need to reset these? What if only two of the three were true?
validCurrent = false;
validDaily = false;
validHourly = false;
}
}
expList.setAdapter(adapter);
/* If you are setting adapter every time *updateWhenReady* is invoked, no need to notifyDataSetChanged, because its a new adapter and layout will be drawn fresh */
//adapter.notifyDataSetChanged();
}
In getChildView
inflate using fragment_daily_list_parent
copy-past error?
Related
Confusing at it may seem, I am confused of what is happening too. I have an application in which there is a listview that displays values and when a row is pressed, the third value of the row will display a value.
Example is: third value is 30 and when it's pressed, it should be divided by 6, so the answer should be 5.
But when I scroll in the listview, the checkbox becomes unchecked and the third value of the row goes back to its old value (30).
Is there any way to keep the checkbox from being checked and the value of the row preserved when clicked?
Here's the snippet of my code.
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#RequiresApi(api = Build.VERSION_CODES.N)
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
CheckBox checkBox = (CheckBox)view.findViewById(R.id.checkmark);
TextView tv3 = (TextView)view.findViewById(R.id.tx_counter);
EditText editText = (EditText)findViewById(R.id.editText3);
String yy = editText.getText().toString().trim();
String shitts = listView.getItemAtPosition(position).toString();
try {
String[] a = shitts.split(", ");
String[] b = a[1].split("=");
String[] sep = a[0].split("=");
String betnumber = sep[1];
String betamount= b[1];
if (view != null) {
checkBox.setChecked(!checkBox.isChecked());
if(checkBox.isChecked()){
//sort number
final String sorted = betnumber.chars().sorted().mapToObj(c -> Character.valueOf((char)c).toString()).collect(Collectors.joining());
System.out.println(sorted);
//check if double digit
Boolean checker = doubleChecker(sorted);
if (checker == true){
Toast.makeText(getApplicationContext(),"DOUBLE DIGIT", LENGTH_SHORT).show();
int answer = Integer.parseInt(betamount) / 3;
tv3.setText(String.valueOf(answer));
}else{
Toast.makeText(getApplicationContext(),"NOT DOUBLE DIGIT", LENGTH_SHORT).show();
int answer;
if(yy.equals("")){
answer = Integer.parseInt(betamount) / 6;
tv3.setText(String.valueOf(answer));
}else{
answer = (Integer.parseInt(betamount) - Integer.parseInt(yy)) / 6;
tv3.setText(String.valueOf(answer));
}
}
//TODO save to array to send
}else{
//TODO mistake RETURN tv3 to old value
}
}
}catch (Exception e){
}
}
});
Here's my adapter.
class MyAdapter extends BaseAdapter {
private ArrayList<HashMap<String, String>> mData;
public MyAdapter(ArrayList<HashMap<String, String>> mData2) {
this.mData = mData2;
}
#Override
public int getCount() {
return mData.size();
}
#Override
public Object getItem(int i) {
return this.mData.get(i);
}
#Override
public long getItemId(int i) {
return i;
}
#Override
public View getView(int i, View view, ViewGroup viewGroup) {
view = getLayoutInflater().inflate(R.layout.row_layout, null);
TextView tx_number = (TextView) view.findViewById(R.id.tx_number);
TextView tx_amount = (TextView) view.findViewById(R.id.tx_amount);
TextView tx_counter = (TextView) view.findViewById(R.id.tx_counter);
String betid = mData.get(i).get("betid");
if(betid!=null){
String betnumber = mData.get(i).get("betnumber");
String amountTarget = mData.get(i).get("amountTarget");
String amountRamble = mData.get(i).get("amountRamble");
tx_number.setText(betnumber);
tx_amount.setText(amountTarget);
tx_counter.setText(amountRamble);
}
return view;
}
}
Replace your adapter code with:
public class MyAdapter extends BaseAdapter {
private ArrayList<HashMap<String, String>> mData;
public MyAdapter(ArrayList<HashMap<String, String>> mData2) {
this.mData = mData2;
}
#Override
public int getCount() {
return mData.size();
}
#Override
public Object getItem(int i) {
return this.mData.get(i);
}
#Override
public long getItemId(int i) {
return i;
}
#Override
public View getView(int i, View convertView, ViewGroup viewGroup) {
View mView = convertView;
String betid = mData.get(i).get("betid");
ViewHolder holder ;
if (mView == null) {
Context context = viewGroup.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
mView = inflater.inflate(R.layout.row_layout, null,false);
holder = new ViewHolder();
holder.tx_number = (TextView) mView.findViewById(R.id.tx_number);
holder.tx_amount = (TextView) mView.findViewById(R.id.tx_amount);
holder.tx_counter = (TextView) mView.findViewById(R.id.tx_counter);
mView.setTag(holder);
} else {
holder = (ViewHolder) mView.getTag();
}
if (betid != null) {
String betnumber = mData.get(i).get("betnumber");
String amountTarget = mData.get(i).get("amountTarget");
String amountRamble = mData.get(i).get("amountRamble");
holder.tx_number.setText(betnumber);
holder.tx_amount.setText(amountTarget);
holder.tx_counter.setText(amountRamble);
}
return mView;
}
private static class ViewHolder {
TextView tx_number;
TextView tx_amount;
TextView tx_counter;
}
}
I added new code with ViewHolder.
I am a French student, sorry for my mistakes.
I have to do a major project of 6 months to validate my studies. This project consists of creating an Android application.
My application consists of a listView with a custom adapter (TextView and CheckBox).
My problem is that I want to check a CheckBox that is not in the current view of my listView. For example if I want to check a checkbox at the bottom of the list and I am at the top of it (it is not visible on the screen). The checkbox check is not the right one, it ticks one randomly in the current view.
Picture ListView
Here is the view code:
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) selectActivity.getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.station_list_item, null);
}
//Handle TextView and display string from your list
TextView textViewListNomStation = (TextView)view.findViewById(R.id.textViewListNomStation);
//Log.i(tag, "nom :" +infosStationsCapteurs.cInfosStationArrayList.get(position).getNomStation() );
textViewListNomStation.setText(infosStationsCapteurs.getcInfosStationArrayList().get(position).getNomStation() + " ID : " + infosStationsCapteurs.getcInfosStationArrayList().get(position).getIdStation());
TextView textViewListInfosStation = (TextView)view.findViewById(R.id.textViewListInfosStation);
String formatInfos = "Lat : " + infosStationsCapteurs.getcInfosStationArrayList().get(position).getPositionGPS().getLatitude() + " Lon : " + infosStationsCapteurs.getcInfosStationArrayList().get(position).getPositionGPS().getLongitude();
textViewListInfosStation.setText(formatInfos);
//Handle buttons and add onClickListeners
CheckBox checkBoxStation = (CheckBox) view.findViewById(R.id.checkBoxStation);
checkBoxTab[position] = checkBoxStation;
checkBoxTab[position].setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// Log.i(tag, "Bouton :" + buttonView.getId() + " Status " + isChecked);
if (isChecked == true)
{
mCheckedState[position]=true;
selectActivity.getTableauCapteurs().addHashSetstationChecked((cInfosStation)getItem(position));
selectActivity.getTableauCapteurs().createTable();
}
if (isChecked == false){
mCheckedState[position]=false;
selectActivity.getTableauCapteurs().deleteHashSetstationChecked((cInfosStation)getItem(position));
selectActivity.getTableauCapteurs().createTable();
}
}
});
checkBoxTab[position].setChecked(mCheckedState[position]);
return view;
}
Here is the code that allows me to check a checkbox in the listView
public void checkListStation(int id, boolean etat)
{
//Log.i(tag,"CheckListStation : NBR STATION : " + infosStationsCapteurs.getcInfosStationArrayList().size());
for (int i = 0;i<infosStationsCapteurs.getcInfosStationArrayList().size();i++)
{
//Log.i(tag, "CHECK " + infosStationsCapteurs.getcInfosStationArrayList().get(i).getNomStation() + " : "+name);
if (infosStationsCapteurs.getcInfosStationArrayList().get(i).getIdStation()==id)
{
mCheckedState[i]=etat;
if (checkBoxTab[i]!=null)
{
checkBoxTab[i].setChecked(etat);
Log.i(tag, "Checkbox : " + i + " : " + checkBoxTab[i].isChecked() + "taille : " + checkBoxTab.length);
}
}
}
this.notifyDataSetChanged();
}
Here is an image that shows the problem. If I want to check the one down it will check the top one instead:
Example
I hope I have been clear enough.
Thank you very much for your help.
Can you post the picture of what you want to do?It is not clear.
But what I think you want one listview which have multiple items and each item holds one checkbox.If it is then you can do it by using custom listview with adapter.
You can refer below caode
public class GeneratedOrderListAdapter extends BaseAdapter {
Context mContext;
ViewHolder holder;
Typeface tf_bold, tf_regular;
ArrayList<GenerateOrder> arrayListgeneratOrder;
public GeneratedOrderListAdapter(Context context, ArrayList<GenerateOrder> arrayListgeneratOrder) {
mContext = context;
this.arrayListgeneratOrder = new ArrayList<>();
this.arrayListgeneratOrder = arrayListgeneratOrder;
this.tf_bold = Typeface.createFromAsset(mContext.getAssets(), "opensans_semibold.ttf");
this.tf_regular = Typeface.createFromAsset(mContext.getAssets(), "opensans_regular.ttf");
}
#Override
public int getCount() {
return arrayListgeneratOrder.size();
}
#Override
public Object getItem(int i) {
return null;
}
#Override
public long getItemId(int i) {
return 0;
}
static class ViewHolder {
TextView mOrderNO;
TextView mCustomerName;
TextView mStatus;
TextView mTotalAmount;
TextView mtextOrderNO;
TextView mtextCustomerName;
TextView mtextStatus;
TextView mtextTotalAmount;
RelativeLayout relback;
}
#Override
public View getView(int position, View view, ViewGroup viewGroup) {
LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (view == null) {
view = mInflater.inflate(R.layout.order_list, null);
holder = new ViewHolder();
holder.mtextStatus = (TextView) view.findViewById(R.id.txt_t_status);
holder.mtextOrderNO = (TextView) view.findViewById(R.id.txt_title_orderno);
holder.mtextCustomerName = (TextView) view.findViewById(R.id.txt_t_customer);
holder.mtextTotalAmount = (TextView) view.findViewById(R.id.txt_t_amount);
holder.mStatus = (TextView) view.findViewById(R.id.txt_status);
holder.mOrderNO = (TextView) view.findViewById(R.id.txt_orderno);
holder.mCustomerName = (TextView) view.findViewById(R.id.txt_customer);
holder.mTotalAmount = (TextView) view.findViewById(R.id.txt_amount);
holder.relback=(RelativeLayout)view.findViewById(R.id.rel_back);
// setTypeFace();
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
try {
holder.mStatus.setText(arrayListgeneratOrder.get(position).getOrderStatus());
holder.mTotalAmount.setText(arrayListgeneratOrder.get(position).getAmount());
holder.mCustomerName.setText(arrayListgeneratOrder.get(position).getCustomerName());
holder.mOrderNO.setText(arrayListgeneratOrder.get(position).getOrderNo());
if(position%2==0){
holder.relback.setBackgroundColor(Color.parseColor("#f4fff5"));
}else{
holder.relback.setBackgroundColor(Color.parseColor("#ffffff"));
}
} catch (Exception e) {
e.printStackTrace();
}
return view;
}
private void setTypeFace() {
holder.mStatus.setTypeface(tf_regular);
holder.mTotalAmount.setTypeface(tf_regular);
holder.mCustomerName.setTypeface(tf_regular);
holder.mOrderNO.setTypeface(tf_regular);
holder.mtextStatus.setTypeface(tf_regular);
holder.mtextOrderNO.setTypeface(tf_regular);
holder.mtextCustomerName.setTypeface(tf_regular);
holder.mtextTotalAmount.setTypeface(tf_regular);
}
}
In your model class add CheckFlag paramter and initialize to zero
//Handle buttons and add onClickListeners
CheckBox checkBoxStation = (CheckBox) view.findViewById(R.id.checkBoxStation);
int check_flag=infosStationsCapteurs.getcInfosStationArrayList().get(position).getPositionGPS().getCheckFlag();
if(check_flag==1)
{
checkBoxStation.setChecked(true);
}
else
{
checkBoxStation.setChecked(false);
}
checkBoxStation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//Log.i(tag, "Bouton :" + buttonView.getId() + " Status " + isChecked);
if (isChecked)
{
infosStationsCapteurs.getcInfosStationArrayList().get(position).getPositionGPS().setCheckFlag(1);
}
else{
{
infosStationsCapteurs.getcInfosStationArrayList().get(position).getPositionGPS().setCheckFlag(0);
}
notifyDataSetChanged();
}
});
Use the code below.
This is adater class
public class AttendanceAdapter extends BaseAdapter{
Context ctx;
LayoutInflater lInflater;
ArrayList<Student> objects;
public AttendanceAdapter(Context context, ArrayList<Student> students) {
ctx = context;
objects = students;
lInflater = (LayoutInflater) ctx
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
return objects.size();
}
#Override
public Object getItem(int position) {
return objects.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = lInflater.inflate(R.layout.atndnc_items, parent, false);
}
Student s = getStudent(position);
((TextView) view.findViewById(R.id.txtRollno)).setText(s.rollno);
((TextView) view.findViewById(R.id.txtName)).setText(s.fname+" "+s.mname+" "+s.lname);
final CheckBox cbAtnd = (CheckBox) view.findViewById(R.id.chckTick);
cbAtnd.setOnCheckedChangeListener(myCheckChangList);
cbAtnd.setTag(position);
cbAtnd.setChecked(s.chck);
return view;
}
Student getStudent(int position) {
return ((Student) getItem(position));
}
public ArrayList<Student> getBox() {
ArrayList<Student> box = new ArrayList<Student>();
for (Student s : objects) {
box.add(s);
}
return box;
}
CompoundButton.OnCheckedChangeListener myCheckChangList = new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
getStudent((Integer) buttonView.getTag()).chck = isChecked;
}
};}
Then create one object of your adater and call this method from your main activity.Here boxadater is the object of my Adapter class.
public void getValue(){
for (Student s :boxAdapter.getBox()) {
attendance.attendancelist.add(new Attendance( s.rollno,s.fname+" "+s.mname+" "+s.lname,s.chck));
}
}
hi friends i am not able to understand how to set text in the same row of the list view where i am having two button with text view at the center but when i am trying to increment or decrement the effect is showing on the next row but not the row on which i want the changes to be applied
CartAdapter.java
public class Cart_Adapter extends BaseAdapter {
Context cartcontext;
List<MobiData> cartlist;
LayoutInflater inflater;
cartlist cartdata;
public ArrayList<Integer> quantity = new ArrayList<Integer>();
CustomButtonListener customButtonListener;
public Cart_Adapter(Context cartcontext, List<MobiData> cartlist) {
this.cartcontext = cartcontext;
this.cartlist = cartlist;
}
#Override
public int getCount() {
return cartlist.size();
}
#Override
public Object getItem(int position) {
return cartlist.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
inflater = (LayoutInflater) cartcontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
cartdata = new cartlist();
convertView = inflater.inflate(R.layout.cart_row, parent, false);
cartdata.decrement = (TextView) convertView.findViewById(R.id.decrement);
cartdata.single = (TextView) convertView.findViewById(R.id.single);
cartdata.single.setTag(position);
cartdata.increment = (TextView) convertView.findViewById(R.id.increment);
cartdata.increment.setTag(position);
cartdata.cancel = (TextView) convertView.findViewById(R.id.cancel);
cartdata.vcmedname = (TextView) convertView.findViewById(R.id.vcmedname);
cartdata.vcmedprice = (TextView) convertView.findViewById(R.id.vcmedprice);
Typeface carttext = Typeface.createFromAsset(cartcontext.getAssets(), "fonts/fontawesome.ttf");
cartdata.decrement.setTypeface(carttext);
cartdata.increment.setTypeface(carttext);
cartdata.cancel.setTypeface(carttext);
convertView.setTag(cartdata);
} else {
cartdata = (cartlist) convertView.getTag();
}
MobiData newcart = cartlist.get(position);
cartdata.vcmedname.setText(newcart.getVcmedname());
cartdata.vcmedprice.setText(newcart.getVcmedprice());
cartdata.single.setText(newcart.getVcqty());
final String cartids = newcart.getVcmedid();
cartdata.cancel.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
cartlist.remove(position);
notifyDataSetChanged();
}
});
cartdata.increment.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick( View v) {
if (customButtonListener !=null){
int plus = Integer.parseInt(cartdata.single.getText().toString());
plus++;
int plus = Integer.parseInt(cartdata.single.getText().toString());
plus++;
cartdata.single.setText(String.valueOf(plus));
SharedPreferences viewpref = cartcontext.getSharedPreferences("datapref", Context.MODE_PRIVATE);
String cartuid = viewpref.getString("uid", "");
String carttempid = viewpref.getString("tempid", "");
String incremnturl = "http://sampletemplates.net/mobichemist/json/cart_process.php?mid=" + cartids + "&userid=" + cartuid + "&tempid=" + carttempid;
Log.d("Incremnturl", incremnturl);
JsonArrayRequest incrementarray = new JsonArrayRequest(Request.Method.GET, incremnturl, (String) null, new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
for (int i = 0; i < response.length(); i++) {
try {
JSONObject incrobj = response.getJSONObject(i);
int plus = Integer.parseInt(cartdata.single.getText().toString());
plus++;
cartdata.single.setText(String.valueOf(plus));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Log.d("Incrementurl", String.valueOf(error));
}
});
incrementarray.setRetryPolicy(new DefaultRetryPolicy(50000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
AppController.getInstance().addToRequestQueue(incrementarray);
}
});
cartdata.decrement.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
int i = Integer.parseInt(cartdata.single.getText().toString());
i--;
if (i <= 0) {
Toast.makeText(Single_Cart_Page.this, "Minimum Quantity is 1", Toast.LENGTH_SHORT).show();
} else {
cartdata.single.setText(String.valueOf(i));
}
}
});
return convertView;
}
static class cartlist {
TextView decrement, single, increment, cancel, vcmedname, vcmedprice;
}
try this and add your other code.
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.cart_row, parent, false);
holder = new ViewHolder();
holder.decrement = (TextView) convertView.findViewById(R.id.decrement);
holder.single = (TextView) convertView.findViewById(R.id.single);
holder.increment = (TextView) convertView.findViewById(R.id.increment);
holder.cancel = (TextView) convertView.findViewById(R.id.cancel);
holder.vcmedname = (TextView) convertView.findViewById(R.id.vcmedname);
holder.vcmedprice = (TextView) convertView.findViewById(R.id.vcmedprice);
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
Typeface carttext = Typeface.createFromAsset(cartcontext.getAssets(), "fonts/fontawesome.ttf");
holder.decrement.setTypeface(carttext);
holder.increment.setTypeface(carttext);
holder.cancel.setTypeface(carttext);
MobiData newcart = cartlist.get(position);
holder.vcmedname.setText(newcart.getVcmedname());
holder.vcmedprice.setText(newcart.getVcmedprice());
holder.single.setText(newcart.getVcqty());
final String cartids = newcart.getVcmedid();
holder.cancel.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
cartlist.remove(position);
notifyDataSetChanged();
}
});
return convertView;
}
static class ViewHolder {
private TextView decrement;
private TextView single;
private TextView increment;
private TextView vcmedname;
private TextView vcmedprice;
}
Use ArrayAdaper instead of Base Adapter with ViewHolder. Don't set setTag(position) manually for all views.
Find ViewHolder example here https://dzone.com/articles/optimizing-your-listview .It will solve your indexing problem. ViewHolder class sets all views position. Also find more description on Hold View Objects in a View Holder
I have 2 activities with listview and when I go to activity B and back to A and click, I get error:
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131492961, class android.widget.ListView) with Adapter(class com.example.example.ItemListBaseAdapter)]
When I need to call notifyDataSetChanged()?
In my acticities or in ItemListBaseAdapter Class?
The code in my activities:
ArrayList<ItemDetails> image_details = GetSearchResults();
final ListView lv1 = (ListView) findViewById(R.id.list);
lv1.setAdapter(new ItemListBaseAdapter(getApplicationContext(), image_details));
lv1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Object o = lv1.getItemAtPosition(position);
}
});
private ArrayList<ItemDetails> GetSearchResults() {
ArrayList<ItemDetails> results = new ArrayList<ItemDetails>();
for(int i = 0;i<Code.size();i++) {
ItemDetails item_details = new ItemDetails();
item_details.setName(getString(R.string.newanswer));
item_details.setItemDescription(Book.get(i) + " - " + getString(R.string.page) + " " + Page.get(i) + " " + getString(R.string.exercise) + " " + Exercise.get(i) + "\n" + getString(R.string.clicktoshow));
item_details.setImageNumber(2000);
results.add(item_details);
}
return results;
}
The ItemListBaseAdapter Class:
public class ItemListBaseAdapter extends BaseAdapter {
private static ArrayList<ItemDetails> itemDetailsrrayList;
private LayoutInflater l_Inflater;
public ItemListBaseAdapter(Context context, ArrayList<ItemDetails> results) {
itemDetailsrrayList = results;
l_Inflater = LayoutInflater.from(context);
}
public int getCount() {
return itemDetailsrrayList.size();
}
public Object getItem(int position) {
return itemDetailsrrayList.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = l_Inflater.inflate(R.layout.item_details_view, null);
holder = new ViewHolder();
holder.txt_itemName = (TextView) convertView.findViewById(R.id.name);
holder.txt_itemDescription = (TextView) convertView.findViewById(R.id.itemDescription);
holder.itemImage = (ImageView) convertView.findViewById(R.id.photo);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.txt_itemName.setText(itemDetailsrrayList.get(position).getName());
holder.txt_itemDescription.setText(itemDetailsrrayList.get(position).getItemDescription());
if(itemDetailsrrayList.get(position).getImageNumber() == 1999) {
holder.itemImage.setImageResource(R.drawable.person);
}
else {
if(itemDetailsrrayList.get(position).getImageNumber() == 2000) {
holder.itemImage.setImageResource(R.drawable.icon);
}
else {
byte[] a = itemDetailsrrayList.get(position).getPicture();
Bitmap bmp = BitmapFactory
.decodeByteArray(
a, 0,
a.length);
holder.itemImage.setImageBitmap(bmp);
}
}
return convertView;
}
static class ViewHolder {
TextView txt_itemName;
TextView txt_itemDescription;
ImageView itemImage;
}}
I have listview in a listview on scrolling the inner listview content goes empty ,i am getting tags still getting problem, so to save the data i saved it list values in hasmap and getting from there. but one list value is saved not other ,any one please give me clue or solution how to get the value from "finish data list" as geting "unit" from "item" list and "feet" from "finish" data list or any other problem in my below code
public class ViewAdapter extends BaseExpandableListAdapter {
private int lastExpandedGroupPosition;
private ExpandableListView expandableListView;
private LayoutInflater inflater;
private List<String> groupItems;
private HashMap<String, List<String>> childItems;
public int childCount = 0;
private Context context;
private List<List<String>> firstLevelItems;
HashMap<String, List<String>> firstLevelItems1;
private List<String> endData;
private HashMap<String, String> endHashmap;
private List<List<String>> finishData;
private int finishDataPosition;
private List<String> photos;
private int lengthCounter;
private int someCounter;
public ViewAdapter(Context context, ExpandableListView listView, List<String> groupItems) {
if (listView != null)
expandableListView = listView;
if (context != null)
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (groupItems != null && !groupItems.isEmpty())
this.groupItems = groupItems;
childItems = new HashMap<>();
firstLevelItems1 = new HashMap<>();
firstLevelItems = new ArrayList<>();
endData = new ArrayList<>();
endHashmap = new HashMap<>();
finishData = new ArrayList<>();
photos = new ArrayList<>();
this.context = context;
ImageLoaderInit(context);
lengthCounter = 0;
}
#Override
public int getGroupCount() {
return groupItems.size();
}
#Override
public int getChildrenCount(int groupPosition) {
return childCount;
}
#Override
public Object getGroup(int groupPosition) {
return null;
}
#Override
public Object getChild(int groupPosition, int childPosition) {
return null;
}
#Override
public long getGroupId(int groupPosition) {
return 0;
}
#Override
public long getChildId(int groupPosition, int childPosition) {
return 0;
}
#Override
public boolean hasStableIds() {
return false;
}
#Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View view = convertView;
ViewHolder vh = null;
;
if (view == null) {
vh = new ViewHolder();
view = inflater.inflate(R.layout.view_main_group_item, parent, false);
vh.title = (TextView) view.findViewById(R.id.view_main_group_title);
vh.arrow = (ImageView) view.findViewById(R.id.view_main_group_arrow);
view.setTag(vh);
} else
vh = (ViewHolder) view.getTag();
if (isExpanded) {
view.setPadding(0, 0, 0, 0);
lastExpandedGroupPosition = groupPosition;
vh.arrow.setImageResource(R.drawable.icon_down_10);
} else {
view.setPadding(0, 0, 0, 15);
}
vh.title.setText(groupItems.get(groupPosition));
return view;
}
#Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
View view = convertView;
ViewHolder vh = null;
if (view == null) {
vh = new ViewHolder();
view = inflater.inflate(R.layout.view_main_child_item, parent, false);
vh.title = (TextView) view.findViewById(R.id.view_main_child_item);
vh.photoLayout = (LinearLayout) view.findViewById(R.id.view_main_child_bottom_layout);
vh.firstLevelItemsLV = (ListView) view.findViewById(R.id.view_main_child_first_level_items);
/* if (childPosition < childCount - 1) {
vh.photoLayout.setVisibility(View.GONE);
} else*/ {
vh.firstPhoto = (ImageView) view.findViewById(R.id.view_main_first_photo);
vh.secondPhoto = (ImageView) view.findViewById(R.id.view_main_second_photo);
vh.thirdPhoto = (ImageView) view.findViewById(R.id.view_main_third_photo);
vh.thirdPhoto.setImageResource(R.drawable.default1);
vh.secondPhoto.setImageResource(R.drawable.default1);
vh.firstPhoto.setImageResource(R.drawable.default1);
}
view.setTag(vh);
} else {
vh = (ViewHolder) view.getTag();
}
if (childItems.get(groupPosition + "") != null && !childItems.get(groupPosition + "").isEmpty()) {
String s = "• " + childItems.get(groupPosition + "").get(childPosition) + " :";
vh.title.setText(s);
}
for (int i = 0; i < firstLevelItems.get(childPosition).size(); i++) {
if (finishData.size() > (lengthCounter)) {
if (finishData.get(lengthCounter).size() > someCounter) {
someCounter = finishData.get(lengthCounter).size() + 1;
}
} else
// someCounter = finishData.get(finishData.get(lengthCounter).size()-1).size();
/*{
{
}
}*/lengthCounter++;
}
int i = firstLevelItems.get(childPosition).size();
Log.i("size ", i + "");
// someCounter= finishData.get(finishDataPosition).size()+2;
Log.e("LENGTH", "Child: " + lengthCounter);
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
float oneItemDp1 = display.getHeight();
float oneItemDp = oneItemDp1 / 65;
// float oneItemDp = 40 / context.getResources().getDisplayMetrics().density;
int heighy = (int) oneItemDp * (firstLevelItems.get(childPosition).size() +
i + 1);
vh.firstLevelItemsLV.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, heighy
));
someCounter = 0;// by me
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) vh.firstLevelItemsLV.getLayoutParams();
mlp.setMargins(30, 0, 0, 0);
FirstLevelAdapter firstAdapter = new FirstLevelAdapter(context, firstLevelItems.get(childPosition));
vh.firstLevelItemsLV.setAdapter(firstAdapter);
if (vh.firstPhoto != null) {
vh.firstPhoto.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (photos.size() >= 1) {
Intent intent = new Intent(context, EnlargeImageActivity.class);
String photo1 = photos.get(0);
intent.putExtra("photo1", photo1);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} else
Toast.makeText(context, "New image to show", Toast.LENGTH_SHORT).show();
;
}
});
}
if (vh.secondPhoto != null) {
vh.secondPhoto.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (photos.size() >= 2) {
Intent intent = new Intent(context, EnlargeImageActivity.class);
String photo1 = photos.get(1);
intent.putExtra("photo1", photo1);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} else
Toast.makeText(context, "New image to show", Toast.LENGTH_SHORT).show();
;
}
});
}
if (vh.thirdPhoto != null) {
vh.thirdPhoto.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (photos.size() >= 3) {
Intent intent = new Intent(context, EnlargeImageActivity.class);
String photo1 = photos.get(2);
intent.putExtra("photo1", photo1);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} else {
Toast.makeText(context, "New image to show", Toast.LENGTH_SHORT).show();
;
}
}
});
}
if (vh.firstPhoto != null) {
if (photos.size() >= 1) {
if (!this.photos.isEmpty()) {
vh.firstPhoto.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageLoader.displayImage("file://" + Uri.parse(this.photos.get(0)), vh.firstPhoto, imageOptions);
}
} else {
vh.firstPhoto.setImageResource(R.drawable.default1);
}
}
if (vh.secondPhoto != null) {
if (photos.size() >= 2) {
if (this.photos.size() > 1 && !this.photos.isEmpty()) {
vh.secondPhoto.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageLoader.displayImage("file://" + Uri.parse(this.photos.get(1)), vh.secondPhoto, imageOptions);
}
} else {
//vh.secondPhoto.setImageDrawable(context.getResources().getDrawable(R.drawable.icon_save));
//vh.secondPhoto.setMaxHeight(100);
vh.secondPhoto.setImageResource(R.drawable.default1);
}
}
if (vh.thirdPhoto != null) {
if (photos.size() >= 3) {
if (this.photos.size() > 2 && !this.photos.isEmpty()) {
vh.thirdPhoto.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageLoader.displayImage("file://" + Uri.parse(this.photos.get(2)), vh.thirdPhoto, imageOptions);
}
} else {
vh.thirdPhoto.setImageResource(R.drawable.default1);
}
}
return view;
}
#Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
#Override
public void onGroupExpanded(final int groupPosition) {
if (groupPosition != lastExpandedGroupPosition) {
expandableListView.collapseGroup(lastExpandedGroupPosition);
}
super.onGroupExpanded(groupPosition);
lastExpandedGroupPosition = groupPosition;
}
public void setChildView(int groupPosition, List<String> childItems, List<List<String>> firstLevelItems,
List<String> endData, List<List<String>> photos) {
if (childItems != null && !childItems.isEmpty()) {
childCount = childItems.size();
this.childItems.put(groupPosition + "", childItems);
}
if (firstLevelItems != null && !firstLevelItems.isEmpty()) {
this.firstLevelItems.clear();
this.firstLevelItems.addAll(firstLevelItems);
// firstLevelItems1.put(groupPosition + "", firstLevelItems);
}
if (endData != null && !endData.isEmpty()) {
finishData.clear();
finishDataPosition = 0;
someCounter = 0;
for (int i = 0; i < endData.size(); i++) {
List<String> tempList = new ArrayList<>();
List<String> splitedList = new ArrayList<>();
tempList = Arrays.asList(endData.get(i).split("\\|"));
for (int j = 0; j < tempList.size(); j++) {
if (!tempList.get(j).contains("Other")) {
if (!tempList.get(j).contains("Comment Box")) {
splitedList.add(/*Arrays.asList(*/tempList.get(j)/*.split(":"))*/);
}
}
}
finishData.add(splitedList);
}
}
List<String> tempPhotoList = new ArrayList<>();
if (photos != null && !photos.isEmpty()) {
this.photos.clear();
for (int i = 0; i < photos.size(); i++) {
for (int x = 0; x < photos.get(i).size(); x++) {
tempPhotoList.addAll(Arrays.asList(photos.get(i).get(x).split("\\|")));
}
}
List<String> photoBuffer = new ArrayList<>();
for (String name : tempPhotoList) {
if (name.contains(".ABCInventory")) {
photoBuffer.add(name);
Log.e("TAG", name);
}
}
this.photos = photoBuffer;
}
}
private class FirstLevelAdapter extends BaseAdapter {
private LayoutInflater inflater;
private List<String> items;
private Context _context;
private SharedPreferences sharedPreferences;
private String firstLevel;
private ModelData md;
private String s1;
HashMap<Integer, View> hashMap = new HashMap<Integer, View>();
public FirstLevelAdapter(Context context, List<String> objects) {
if (objects != null) {
items = objects;
}
_context = context;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
return items.size();
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder vh=null;
if (items != null && !items.isEmpty()) {
firstLevelItems1.put(position + "", items);
}
if (convertView == null) {
md = new ModelData();
/* if (hashMap.containsKey(position)) {
return hashMap.get(position);
}*/
try {
{
s1 = "• " + firstLevelItems1.get(position + "").get(position) + " :" ;
md.finalFirtstLevel = s1;
}
}catch(Exception e)
{
e.printStackTrace();
}
vh = new ViewHolder();
convertView = inflater.inflate(R.layout.view_main_child_second_item, parent, false);
vh.item = (TextView) convertView.findViewById(R.id.child_second_item);
vh.elements = (ListView) convertView.findViewById(R.id.child_third_level_items);
// vh.item.setText(s);
vh.item.setText(md.finalFirtstLevel);
convertView.setTag(vh);
/* hashMap.put(position, convertView);*/
} else {
vh = (ViewHolder) convertView.getTag();
}
if (finishData.size() > (finishDataPosition)) // by me
if (finishData.get(finishDataPosition).size() < 2) {
String[] split = finishData.get(finishDataPosition).get(0).split(":");
for (int i = 0; i < finishData.get(finishDataPosition).size(); i++) {
Log.i("split value ", finishData.get(finishDataPosition).get(i) + split[1] + " finishDataPosition " + finishDataPosition);
}
if (split[1] != null && !split[1].isEmpty()) {
md = new ModelData();
String s = "• " + firstLevelItems1.get(position + "").get(position) + " :" + split[1];
md.finalFirtstLevel = s;
vh.item.setText(md.finalFirtstLevel);
}
} else {
md = new ModelData();
String s = "• " + firstLevelItems1.get(position + "").get(position) + " :" ;
md.finalFirtstLevel1 = s;
vh.item.setText(md.finalFirtstLevel1);
float oneItemDp = 10 / _context.getResources().getDisplayMetrics().density;
Log.e("LENGTH", "Adapter: " + lengthCounter);
vh.elements.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
(int) oneItemDp * someCounter));
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) vh.elements
.getLayoutParams();
mlp.setMargins(30, 0, 0, 0);
// vh.elements.setAdapter(new FinishDataAdapter(finishData.get(finishDataPosition)));
}
finishDataPosition++;
return convertView;
}
;
public class ModelData {
public String finalFirtstLevel = "";
public String finalFirtstLevel1 = "";
}
}
private class FinishDataAdapter extends BaseAdapter {
private LayoutInflater inflater;
private List<String> items;
public FinishDataAdapter(List<String> objects) {
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
items = objects;
}
#Override
public int getCount() {
return items.size();
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = inflater.inflate(R.layout.view_main_child_finish_item, parent, false);
TextView item = (TextView) view.findViewById(R.id.child_finish_item);
item.setText("• " + items.get(position));
return view;
}
}
private ImageLoader imageLoader;
private DisplayImageOptions imageOptions;
private void ImageLoaderInit(Context context) {
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.memoryCache(new LruMemoryCache(10 * 1024 * 1024))
.memoryCacheSize(50 * 1024 * 1024)
.memoryCacheSizePercentage(20)
.diskCacheSize(300 * 1024 * 1024)
.diskCacheFileCount(375)
.diskCacheFileNameGenerator(new Md5FileNameGenerator())
.defaultDisplayImageOptions(DisplayImageOptions.createSimple())
.build();
imageOptions = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.default1)
.resetViewBeforeLoading(false)
.delayBeforeLoading(0)
.cacheInMemory(true)
.cacheOnDisc(true)
.considerExifParams(true)
.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
.bitmapConfig(Bitmap.Config.RGB_565)
.displayer(new SimpleBitmapDisplayer())
.handler(new Handler())
.build();
imageLoader = ImageLoader.getInstance();
imageLoader.init(config);
}
private class ViewHolder {
ImageView arrow = null;
LinearLayout photoLayout;
ListView firstLevelItemsLV;
TextView title = null;
TextView title1 = null;
ImageView firstPhoto;
ImageView secondPhoto;
TextView item;
ImageView thirdPhoto;
ListView elements;
}
}