Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyAdapter extends ArrayAdapter<String> {
- private int resourceId;
- String name="";
- String phone;
- private ArrayList<String> sites = null;
- private Context context;
- private static class ViewHolder{
- TextView RideDetails;
- EditText mEdit;
- }
- public MyAdapter(Context context, int resource, ArrayList<String> objects,String phone) {
- super(context, resource, objects);
- this.context = context;
- this.resourceId = resource;
- this.sites = objects;
- this.phone=phone;
- }
- @Override
- public String getItem(int position) {
- return sites.get(position);
- }
- @Override
- public int getCount() {
- return sites.size();
- }
- @Override
- public View getView(final int position, View convertView, ViewGroup parent) {
- name = getItem(position);
- View view = convertView;
- if (view == null) {
- LayoutInflater inflater = LayoutInflater.from(getContext());
- view = inflater.inflate(R.layout.home_resource, parent, false);
- }
- TextView mTextView = (TextView) view.findViewById(R.id.ridedetails);
- mTextView.setText(name);
- Button mButton = (Button) view.findViewById(R.id.button);
- mButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Log.d("Name",name);
- String ridetrackno=name.substring(name.indexOf(":")+1,name.indexOf("Source")-2);
- EditText mEdit;
- mEdit = (EditText) view.findViewById(R.id.PriceQuotation);
- String fare=mEdit.getText().toString();
- String myUrl=".....API URL....."+phone+"/"+ridetrackno+"/"+fare;
- Log.d("URL",myUrl);
- HttpGetRequest getRequest = new HttpGetRequest();
- try{
- String result = getRequest.execute(myUrl).get();
- Log.d("Details:",result);
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- });
- return view;
- }
- }
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout
- android:id="@+id/relativeLayout1"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:padding="5dip">
- <TextView
- android:layout_height="wrap_content"
- android:text="TextView"
- android:layout_width="wrap_content"
- android:id="@+id/ridedetails"
- android:layout_marginLeft="2dip">
- </TextView>
- <EditText
- android:layout_height="wrap_content"
- android:hint="Quote Price"
- android:layout_width="wrap_content"
- android:id="@+id/PriceQuotation"
- android:layout_below="@+id/ridedetails"
- android:layout_marginLeft="2dip">
- </EditText>
- <Button
- android:id="@+id/button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignTop="@+id/PriceQuotation"
- android:layout_marginStart="61dp"
- android:layout_toEndOf="@+id/PriceQuotation"
- android:text="Button" />
- </RelativeLayout>
Add Comment
Please, Sign In to add comment