I am trying to make an app that takes the number of sets, and number of reps for each set from the user, and adds rows ( for each set) and checkboxes (for each rep)
for the reps: i made a method that takes the number of reps from the SQLite server, and loops through the number of reps to make the checkboxes.
for the sets: i made list adapter to make each row.
how can i make the reps be contained inside the rows? thanks.
recyclerview adaptor:
'''
package com.example.workouttracker;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
public class WorkoutInterfacesAdapter extends RecyclerView.Adapter<WorkoutInterfacesAdapter.WorkoutInterfaceViewHolder> {
Context mContext;
private ArrayList<WorkoutInterfaceClass> sets;
private LinearLayout linearLayout;
public WorkoutInterfacesAdapter(Context mContext , ArrayList<WorkoutInterfaceClass> sets) {
this.sets = sets;
this.mContext = mContext;
}
#NonNull
#Override
public WorkoutInterfaceViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.workout_interface_item,parent,false);
return new WorkoutInterfacesAdapter.WorkoutInterfaceViewHolder(view);
}
#Override
public void onBindViewHolder(#NonNull WorkoutInterfacesAdapter.WorkoutInterfaceViewHolder holder, int position) {
holder.bind(sets.get(position));
//new code:
holder.itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(mContext,"Set number: " + sets.get(position).numberOfSets + " ,Rep Number: "+sets.get(position).numberOfReps,Toast.LENGTH_LONG).show();
Intent intent = new Intent(mContext,WorkoutInterface.class);
intent.putExtra("workout_sets",sets.get(position).numberOfSets);
intent.putExtra("workout_reps",sets.get(position).numberOfReps);
mContext.startActivity(intent);
}
});
}
#Override
public int getItemCount() {
return sets.size();
}
static class WorkoutInterfaceViewHolder extends RecyclerView.ViewHolder{
TextView numberOfSets;
int numberOfReps;
CheckBox checkBox;
LinearLayout linearLayout;
public WorkoutInterfaceViewHolder(#NonNull View itemView) {
super(itemView);
numberOfSets =itemView.findViewById(R.id.edit_text_number_of_sets_item);
checkBox=itemView.findViewById(R.id.checkbox_number_of_reps_item);
linearLayout=itemView.findViewById(R.id.ll_checkbox_mother);
}
public void bind(WorkoutInterfaceClass sets) {
//
numberOfSets.setText("Set number:" + sets.numberOfSets); ;
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
numberOfReps=sets.numberOfReps;
for (int i = 1; i <= numberOfReps; i++) {
CheckBox checkBox = new CheckBox(linearLayout.getContext());
checkBox.setId(View.generateViewId());
checkBox.setText("Rep: "+checkBox.getId());
checkBox.setOnClickListener((View.OnClickListener) linearLayout.getContext());
System.out.println("Total Number Of Sets:"+numberOfReps + "And the index is : "+ i );
}
}
}}
'''
Try creating a custom layout that will contain all the necessary views and pass the layout in the onCreateView of you adapter class with a layout inflater.
Related
I would like to change the fragment when listview item clicked under Bottom navigation activity
But I have not idea how to write the OnClickListener
Anyone can provide some hints or tell me what wrong in this program?
Here is the program
And thank you for spend the time to view my program
Thank you very much
package com.example.campus.ui.campus;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.example.c.MainActivity;
import com.example.c.R;
import com.example.c.database.campus.CampusData;
import com.example.c.ui.campusInformation.CampusInformationActivity;
import com.example.c.ui.campusInformation.CampusInformationFragment;
import java.util.ArrayList;
import java.util.List;
public class CampusListLayoutAdapter extends BaseAdapter {
private LayoutInflater layoutInflater;
private List<CampusData> campusList = new ArrayList<CampusData>();
private int resourceViewID;
private Context context;
private Context mContext;
static class ViewHolder{
LinearLayout llCampusCard;
TextView tvCampusName;
TextView tvCampusAddress;
ImageView ivCampusImage;
}
public CampusListLayoutAdapter(Context c, List<CampusData> campusList){
context = c;
layoutInflater = LayoutInflater.from(c);
this.campusList = campusList;
}
#Override
public int getCount() {
return campusList.size();
}
#Override
public Object getItem(int i) {
return i;
}
#Override
public long getItemId(int i) {
return i;
}
#Override
public View getView(int i, View view, ViewGroup viewGroup) {
mContext = viewGroup.getContext();
ViewHolder holder = new ViewHolder();
view = layoutInflater.inflate(R.layout.listview_campus, null);
if(view != null){
holder.tvCampusName = view.findViewById(R.id.tvCampusName);
holder.tvCampusAddress = view.findViewById(R.id.tvCampusAddress);
holder.ivCampusImage = view.findViewById(R.id.ivCampusImage);
holder.tvCampusName.setText(campusList.get(i).name);
holder.tvCampusAddress.setText(campusList.get(i).address);
String image = campusList.get(i).image;
resourceViewID = context.getResources().getIdentifier(image, "drawable", context.getPackageName());
holder.ivCampusImage.setImageResource(resourceViewID);
view.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
return view;
}else {
return null;
}
}
}
First of all, create an interface in your adapter class.
public interface Callbacks {
void onItemClick(YourObject object, int position); // arguments as per the requirement
}
change your constructor of adapter as
Callbacks callback;
public CampusListLayoutAdapter(Context c, List<CampusData> campusList, Callbacks callback){
.....
this.callback = callback;
}
Now in your onClick() use..
callback.onItemClick(yourClickedItem, position)
then pass an anonymous or simply implement interface in your activity.
adapter = new CampusListLayoutAdapter(context, list, new CampusListLayoutAdapter.Callbacks() {
#Override
public void onItemClick(Alert_bean alert, int position) {
// do what you want here in activity like changing fragment or view updates
}
});
I'm trying to do a simple project with Recyclerview and Cardview in Android Studio following this tutorial.
But I'm getting an error in onBindViewHolder function line 32 saying it can't resolve the method setText() in imageView and I don't know why since mTitle is not an ImageView and it is a TextView:
package com.example.demoproject;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import android.content.Context;
public class MyAdapter extends RecyclerView.Adapter<MyHolder> {
Context c;
ArrayList<Model> models; // this array list creates a list of arrays which parameters define in my model class
public MyAdapter(Context c, ArrayList<Model> models) {
this.c = c;
this.models = models;
}
#NonNull
#Override
public MyHolder onCreateViewHolder(#NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.row,null); // this line inflate my row
return new MyHolder(view); // this will return my view to holder class
}
#Override
public void onBindViewHolder(#NonNull MyHolder myHolder, int i) {
myHolder.mTitle.setText(models.get(i).getTitle()); // here i is position
}
#Override
public int getItemCount() {
return 0;
}
}
MyHolder.java :
package com.example.demoproject.
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
public class MyHolder extends RecyclerView.ViewHolder {
ImageView mImaeView, mTitle;
public MyHolder(#NonNull View itemView) {
super(itemView);
this.mImaeView = itemView.findViewById(R.id.imageIv);
this.mTitle = itemView.findViewById(R.id.titleTv);
}
}
Your mTile is not a TextView it is a ImageView. Change it to this:
ImageView mImaeView;
TextView mTitle;
And make sure that itemView.findViewById(R.id.titleTv); returns TextView. Check in Your xml file (recycler view item) that You made it eveything well and titleTv is a TextView
because setText() method is set on textview not in imageView
The problem is the adding method is said to be null and I don't know why. All I want to do is to get the values from the expense fragment and add item to the custom recycler view, the value of the item is what I inputted in the expense fragment.
Following is the main screen Java code:
package com.example.admin.test2;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import org.w3c.dom.Text;
import java.util.ArrayList;
/**
* A simple {#link Fragment} subclass.
*/
public class MainScreen extends Fragment {
private ArrayList<ExampleItem> mExampleList;
private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
// Spinner spinner;
EditText amountt;
EditText detailss;
EditText datee;
public MainScreen() {
// Required empty public constructor
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate (R.layout.fragment_main_screen, container, false);
mExampleList = new ArrayList <ExampleItem>();
mExampleList.add(new ExampleItem(R.drawable.others, "", "", "ADD EXPENSES"));
mRecyclerView = view.findViewById(R.id.recyclerView);
mRecyclerView.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager(getContext());
mAdapter = new ExampleAdapter(mExampleList);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mAdapter);
return view;
}
public void insertItem()
{
Bundle bundle = getArguments();
String deTails = bundle.getString("Details");
String aMount = bundle.getString("Amount");
mExampleList.add(0, new ExampleItem(R.drawable.food, "Food & Drink", ""+ deTails, "₱ " + aMount));
mAdapter.notifyDataSetChanged();
}
}
Following is another activity from where the value will come:
package com.example.admin.test2;
import android.app.DatePickerDialog;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
public class Expense extends Fragment {
private ArrayList<ExampleItem> mExampleList;
public Expense() {
// Required empty public constructor
}
//SPINNER
Spinner sp1;
CustomAdapter adapter;
String[] names = {"Food & Drink", "Shopping", "Transportation", "Home", "Bills & Fees", "Entertainment", "Healthcare", "Education", "Beauty", "Others"};
int[] images = {R.drawable.food, R.drawable.shopping, R.drawable.transportation, R.drawable.home, R.drawable.bills, R.drawable.entertainment, R.drawable.medical, R.drawable.education, R.drawable.beauty, R.drawable.others};
//DATE PICKER
private EditText mDisplayDate;
private DatePickerDialog.OnDateSetListener mDateSetListener;
FloatingActionButton fab;
EditText amounttt;
EditText detailsss;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate (R.layout.fragment_expense, container, false);
//spinner
sp1 = (Spinner)view.findViewById(R.id.customSpinner);
adapter = new CustomAdapter(getActivity(), names, images);
sp1.setAdapter(adapter);
//fab onClick - sending values to the recycler view
fab = (FloatingActionButton) view.findViewById(R.id.fabs);
detailsss = (EditText) view.findViewById(R.id.textDetailss) ;
amounttt = (EditText) view.findViewById(R.id.textAmountt);
fab.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
int pos = sp1.getSelectedItemPosition();
String descrptn = detailsss.getText().toString();
String amouunt = amounttt.getText().toString();
Bundle bundle = new Bundle();
bundle.putString("Details", descrptn);
bundle.putString("Amount", amouunt);
bundle.putInt("Position", pos);
android.support.v4.app.FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
MainScreen ms = new MainScreen();
ms.setArguments(bundle);
ms.insertItem();
fragmentTransaction.replace(R.id.replaceLayout, ms);
fragmentTransaction.commit();
}
});
//date picker
mDisplayDate = (EditText) view.findViewById(R.id.datePick);
mDisplayDate.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View v) {
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH);
int day = cal.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dialog = new DatePickerDialog(getActivity(),
android.R.style.Theme_Holo_Light_Dialog_MinWidth,
mDateSetListener,
year, month, day);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
}
});
mDateSetListener = new DatePickerDialog.OnDateSetListener() {
#Override
public void onDateSet(DatePicker view, int year, int month, int day) {
//Calendar calendar = Calendar.getInstance();
//String currentDate = DateFormat.getDateInstance().format(calendar.getTime());
month = month + 1;
String date = month + "-" + day + "-" + year;
mDisplayDate.setText(date);
}
};
return view;
}
}
Following is the Adapter code:
package com.example.admin.test2;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
public class ExampleAdapter extends RecyclerView.Adapter<ExampleAdapter.ExampleViewHolder> {
private ArrayList<ExampleItem> mExampleList;
public static class ExampleViewHolder extends RecyclerView.ViewHolder
{
public ImageView mImageView;
public TextView mLabel;
public TextView mDetails;
public TextView mAmount;
public ExampleViewHolder(View itemView) {
super(itemView);
mImageView = itemView.findViewById(R.id.imageIcon);
mLabel = itemView.findViewById(R.id.textLabel);
mDetails = itemView.findViewById(R.id.textDetails);
mAmount = itemView.findViewById(R.id.textAmount);
}
}
public ExampleAdapter(ArrayList<ExampleItem> exampleList)
{
mExampleList = exampleList;
}
#NonNull
#Override
public ExampleViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.customlist, parent, false);
ExampleViewHolder evh = new ExampleViewHolder(view);
return evh;
}
#Override
public void onBindViewHolder(#NonNull ExampleViewHolder holder, int position) {
ExampleItem currentItem = mExampleList.get(position);
holder.mImageView.setImageResource(currentItem.getmImageResource());
holder.mLabel.setText(currentItem.getMlabel());
holder.mDetails.setText(currentItem.getMdetails());
holder.mAmount.setText(currentItem.getMamount());
}
#Override
public int getItemCount() {
if (mExampleList == null)
return 0;
else
return mExampleList.size();
}
}
And, following is the Item Java code:
package com.example.admin.test2;
public class ExampleItem {
private int mImageResource;
private String mlabel;
private String mdetails;
private String mamount;
public ExampleItem(int imageResource, String label, String details, String amount)
{
mImageResource = imageResource;
mlabel = label;
mdetails = details;
mamount = amount;
}
public int getmImageResource()
{
return mImageResource;
}
public String getMlabel() {
return mlabel;
}
public String getMdetails() {
return mdetails;
}
public String getMamount() {
return mamount;
}
}
for complete codes and the errors, please refer to this link (because the whole code does not fit and exceeded 30000 words): https://textuploader.com/15s40
For me it didn't work like that neither. I recommend you to create a method in your adapter that directly modify the list inside the adapter. So instead of doing:
mExampleList.add(0, new ExampleItem(R.drawable.food, "Food & Drink", ""+ deTails, "₱ " + aMount));
mAdapter.notifyDataSetChanged();
inside your adapter you have a method like:
public void add (ExampleItem itemToAdd) {
mExampleList.add(itemToAdd);
notifyDataSetChanged();
}
and in your activity:
mAdapter.add(new ExampleItem(R.drawable.food, "Food & Drink", ""+ deTails, "₱ " + aMount));
You have added insertItem() method in MAINSCREEN JAVA CODE, but never called in onCreateView() of MAINSCREEN JAVA CODE, I suggest you to add the code of insertItem() in onCreateView() of MAINSCREEN JAVA CODE.
Edit: i have added a demo application, please refer this link
I need help with me RecyclerView. I've build a normal RecyclerView like this here https://www.raywenderlich.com/126528/android-recyclerview-tutorial and now I need your help.
I want to mark a line (the marked line should be grey) in my RecylcerView on long touch (press) with a short vibration from the device to show a delete icon in the marked row. When the row is marked I want to show the deleting icon instead of the profile image. With clicking the back button from the device I'll remove this mark. How can I do this? Thanks for your help!
Row after long click (press/hold):
This is my adapter:
package de.schoolapp.schoolapp;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.List;
/**
* Created by Johannes on 20.02.2017.
*/
public class BenutzerlisteAdapter extends RecyclerView.Adapter<BenutzerlisteAdapter.MyBenutzerlisteHolder> {
private List<Benutzerliste> userList;
private final Context customContext;
public class MyBenutzerlisteHolder extends RecyclerView.ViewHolder {
public TextView userRowName, userRowPermission;
public MyBenutzerlisteHolder(View view) {
super(view);
userRowName = (TextView) view.findViewById(R.id.userRowName);
userRowPermission = (TextView) view.findViewById(R.id.userRowPermission);
}
}
public BenutzerlisteAdapter(java.util.List<Benutzerliste> userList, Context customContext) {
this.userList = userList;
this.customContext = customContext;
}
#Override
public MyBenutzerlisteHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.benutzerliste_liste_row, parent, false);
return new MyBenutzerlisteHolder(itemView);
}
#Override
public void onBindViewHolder(MyBenutzerlisteHolder holder, int position) {
final Benutzerliste userFillList = userList.get(position);
holder.userRowName.setText(customContext.getString(R.string.userRowName) + " " + userFillList.getVorname() + " " + userFillList.getName());
holder.userRowPermission.setText(customContext.getString(R.string.userRowPermission) + " " + userFillList.getBerechtigung());
// OnClickListener for holder
holder.itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(final View v) {
}
});
}
#Override
public int getItemCount() {
return userList.size();
}
}
happy new year to all of you.
I am having a problem with the method onItemClickListener, because when I tried to toast the position and id ,in my second activity, I get zeros.
here is the code, I rely on the position of the image in the array that is why I need to get the position/id accurately.
+
I am duplicating my array in both activities because I don't know how to access it from the second activity?
MainActivity.java
package swe.trial;
import android.content.Context;
import android.widget.ImageView;
import android.view.View;
import android.view.ViewGroup;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.AdapterView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GridView items = (GridView) findViewById(R.id.itemsList);
items.setAdapter(new item_adapter(this));
items.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//if an item is clicked or selceted,then go to the activity itemDetails:
Intent i= new Intent (MainActivity.this, itemDetails.class);
i.putExtra("position", position);
i.putExtra("id", id);
startActivity(i);
}
});
}
}
class item_adapter extends BaseAdapter {
Integer[] picsId = {
R.drawable.pic1,
R.drawable.pic2,
R.drawable.pic3,
R.drawable.pic4,
R.drawable.pic5,
R.drawable.pic6,
R.drawable.pic7};
private Context context;
public item_adapter(Context context) {
this.context = context;
}
public Object getItem(int position) {
return null;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imgview= new ImageView(context);
imgview.setLayoutParams(new GridView.LayoutParams(250,250));
imgview.setScaleType(ImageView.ScaleType.CENTER_CROP);
imgview.setPadding(20,20,20,20);
imgview.setImageResource(picsId[position]);
return imgview;
}
public long getItemId(int position) {
return position;
}
public int getCount (){
return picsId.length;
}
}
itemDetails.java
package swe.trial;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.content.Intent;
import android.widget.ImageView;
import android.widget.TextView;
import android.app.Activity;
import android.net.Uri;
import android.view.View;
import android.widget.Toast;
import java.util.ArrayList;
/**
* Created by good on 1/01/17.
*/
public class itemDetails extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.item);
ArrayList<item> items = new ArrayList<item>();
// items item1=
// Bundle d = getIntent().getExtras();
int id=0;getIntent().getIntExtra("id",id);
int position=0;
getIntent().getIntExtra("position", position);
Toast.makeText( this, "id= " +id + " . and posistion= "+ position, Toast.LENGTH_LONG).show();
Integer[] picsId = {
R.drawable.pic1,
R.drawable.pic2,
R.drawable.pic3,
R.drawable.pic4,
R.drawable.pic5,
R.drawable.pic6,
R.drawable.pic7
};
ImageView imgview = (ImageView) findViewById(R.id.item_image);
imgview.setImageResource(picsId[id+ 1]);
TextView txt= (TextView) findViewById(R.id.pricetxtview);
txt.setText("This is the description provided." + id);
//(id);
// item item1 = {"Red rose", "#/drawable/", 1, 1.25};
// items.add(item1);
// now i will search for the array that holds the given id. and i will retrieve its info and display it again
// in the new layout.
}
}
You misunderstand the way you should use intents.
The right form is like this :
int id =getIntent().getIntExtra("id",0);
int position = getIntent().getIntExtra("position", 0);
when you use getIntExtra , the second parameter is the default value. In case there is not such value with that tag in your intent, it will return that default value.
See Google docs for more info
You have to fetch value according the following way,
int id=0;
int position=0;
i=getIntent().getIntExtra("id",id);
position= getIntent().getIntExtra("position", position);
Toast.makeText( this, "id= " +id + " . and posistion= "+ position, Toast.LENGTH_LONG).show();