Guest User

Untitled

a guest
Mar 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. class MyAdapter extends ArrayAdapter<String> {
  2. private int resourceId;
  3. String name="";
  4. String phone;
  5. private ArrayList<String> sites = null;
  6. private Context context;
  7.  
  8.  
  9. private static class ViewHolder{
  10. TextView RideDetails;
  11. EditText mEdit;
  12. }
  13.  
  14. public MyAdapter(Context context, int resource, ArrayList<String> objects,String phone) {
  15. super(context, resource, objects);
  16. this.context = context;
  17. this.resourceId = resource;
  18. this.sites = objects;
  19. this.phone=phone;
  20. }
  21.  
  22. @Override
  23. public String getItem(int position) {
  24. return sites.get(position);
  25. }
  26.  
  27. @Override
  28. public int getCount() {
  29. return sites.size();
  30. }
  31.  
  32. @Override
  33. public View getView(final int position, View convertView, ViewGroup parent) {
  34. name = getItem(position);
  35. View view = convertView;
  36. if (view == null) {
  37. LayoutInflater inflater = LayoutInflater.from(getContext());
  38. view = inflater.inflate(R.layout.home_resource, parent, false);
  39. }
  40. TextView mTextView = (TextView) view.findViewById(R.id.ridedetails);
  41. mTextView.setText(name);
  42. Button mButton = (Button) view.findViewById(R.id.button);
  43. mButton.setOnClickListener(new View.OnClickListener() {
  44. @Override
  45. public void onClick(View view) {
  46. Log.d("Name",name);
  47. String ridetrackno=name.substring(name.indexOf(":")+1,name.indexOf("Source")-2);
  48.  
  49. EditText mEdit;
  50. mEdit = (EditText) view.findViewById(R.id.PriceQuotation);
  51. String fare=mEdit.getText().toString();
  52.  
  53.  
  54. String myUrl=".....API URL....."+phone+"/"+ridetrackno+"/"+fare;
  55. Log.d("URL",myUrl);
  56. HttpGetRequest getRequest = new HttpGetRequest();
  57. try{
  58. String result = getRequest.execute(myUrl).get();
  59. Log.d("Details:",result);
  60. }
  61. catch(Exception e)
  62. {
  63. e.printStackTrace();
  64. }
  65. }
  66. });
  67.  
  68. return view;
  69. }
  70. }
  71.  
  72. <?xml version="1.0" encoding="utf-8"?>
  73. <RelativeLayout
  74. android:id="@+id/relativeLayout1"
  75. android:layout_width="fill_parent"
  76. android:layout_height="fill_parent"
  77. xmlns:android="http://schemas.android.com/apk/res/android"
  78. android:padding="5dip">
  79. <TextView
  80. android:layout_height="wrap_content"
  81. android:text="TextView"
  82. android:layout_width="wrap_content"
  83. android:id="@+id/ridedetails"
  84. android:layout_marginLeft="2dip">
  85. </TextView>
  86.  
  87. <EditText
  88. android:layout_height="wrap_content"
  89. android:hint="Quote Price"
  90. android:layout_width="wrap_content"
  91. android:id="@+id/PriceQuotation"
  92. android:layout_below="@+id/ridedetails"
  93. android:layout_marginLeft="2dip">
  94. </EditText>
  95.  
  96. <Button
  97. android:id="@+id/button"
  98. android:layout_width="wrap_content"
  99. android:layout_height="wrap_content"
  100. android:layout_alignTop="@+id/PriceQuotation"
  101. android:layout_marginStart="61dp"
  102. android:layout_toEndOf="@+id/PriceQuotation"
  103. android:text="Button" />
  104.  
  105.  
  106. </RelativeLayout>
Add Comment
Please, Sign In to add comment