Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.02 KB | None | 0 0
  1. @Override
  2. public View getView(int position, View convertView, ViewGroup parent) {
  3. View v = convertView;
  4.  
  5. if(v == null) {
  6. LayoutInflater li = LayoutInflater.from(getContext());
  7. v = li.inflate(R.layout.ofertas_app_custom_list, null);
  8. }
  9.  
  10. Ofertas_Application app = items.get(position);
  11.  
  12. if(app != null) {
  13.  
  14. TextView titleText = (TextView)v.findViewById(R.id.textView1);
  15. TextView direccionText = (TextView)v.findViewById(R.id.textView2);
  16. TextView valoracionText = (TextView)v.findViewById(R.id.textView3);
  17.  
  18. if(titleText != null) titleText.setText(app.getNombreEmpresa());//populate textView1
  19.  
  20. if (direccionText !=null) direccionText.setText(app.getDireccionEmpresa());//populate textView2
  21. if (valoracionText !=null) valoracionText.setText(String.valueOf(app.getValoracionEmpresa()));
  22.  
  23.  
  24. ImageView img = (ImageView)v.findViewById(R.id.imageView1);
  25. try {
  26.  
  27. URL url = new URL("http://0.tqn.com/d/webclipart/1/0/5/l/4/floral-icon-5.jpg");
  28.  
  29. HttpGet httpRequest = null;
  30.  
  31. httpRequest = new HttpGet(url.toURI());
  32.  
  33. HttpClient httpclient = new DefaultHttpClient();
  34. HttpResponse response = (HttpResponse) httpclient
  35. .execute(httpRequest);
  36.  
  37. HttpEntity entity = response.getEntity();
  38. BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
  39. InputStream input = b_entity.getContent();
  40.  
  41. Bitmap bitmap = BitmapFactory.decodeStream(input);
  42.  
  43. img.setImageBitmap(bitmap);
  44.  
  45. } catch (Exception ex) {
  46.  
  47. }
  48.  
  49. }
  50.  
  51. return v;
  52. }
  53.  
  54. <?xml version="1.0" encoding="utf-8"?>
  55. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  56. android:layout_width="match_parent"
  57. android:layout_height="wrap_content"
  58. android:background="#5981b2"
  59. android:orientation="vertical" >
  60.  
  61. <ImageView
  62. android:id="@+id/imageView1"
  63. android:layout_width="wrap_content"
  64. android:layout_height="wrap_content"
  65. android:layout_alignParentLeft="true"
  66. android:layout_alignParentTop="true"
  67. android:layout_marginLeft="2dp"
  68. android:src="@drawable/facebook" />
  69.  
  70. <TextView
  71. android:id="@+id/textView3"
  72. android:layout_width="wrap_content"
  73. android:layout_height="wrap_content"
  74. android:layout_alignParentRight="true"
  75. android:layout_centerHorizontal="true"
  76. android:text="30"
  77. android:drawablePadding="10dp"
  78. android:gravity="center"
  79. android:drawableTop="@drawable/valoracion"
  80. android:textAppearance="?android:attr/textAppearanceSmall" />
  81.  
  82. <TextView
  83. android:id="@+id/textView1"
  84. android:layout_width="wrap_content"
  85. android:layout_height="wrap_content"
  86. android:layout_centerHorizontal="true"
  87. android:layout_toLeftOf="@+id/textView3"
  88. android:lines="2"
  89. android:text="Large Text"
  90. android:textColor="#ffffff"
  91. android:textAppearance="?android:attr/textAppearanceLarge"
  92. android:layout_toRightOf="@id/imageView1"
  93. />
  94.  
  95. <TextView
  96. android:id="@+id/textView2"
  97. android:layout_width="wrap_content"
  98. android:layout_height="wrap_content"
  99. android:layout_alignLeft="@+id/textView1"
  100. android:layout_toLeftOf="@+id/textView3"
  101.  
  102. android:layout_below="@+id/textView1"
  103. android:lines="2"
  104. android:text="Small Text esta eb kac case deded eadad"
  105. android:textAppearance="?android:attr/textAppearanceSmall" />
  106.  
  107. </RelativeLayout>
  108.  
  109. new AsyncTask<URL, Integer, Long>(){
  110. @Override
  111. protected Long doInBackground(URL... params) {
  112. try{
  113.  
  114. URL url = new URL("http://0.tqn.com/d/webclipart/1/0/5/l/4/floral-icon-5.jpg");
  115. - - - - - - - -
  116. // add your code to fetch the image
  117. - - - - - - -
  118. img.setImageBitmap(bitmap);
  119. }
  120. catch (Exception e){
  121. System.out.print(e.getMessage());
  122. }
  123. return null;
  124. }
  125. }.execute();
  126.  
  127. @Override
  128. public View getView(int position, View convertView, ViewGroup parent) {
  129. View v = convertView;
  130.  
  131. if(v == null) {
  132. LayoutInflater li = LayoutInflater.from(getContext());
  133. v = li.inflate(R.layout.ofertas_app_custom_list, null);
  134. }
  135.  
  136. Ofertas_Application app = items.get(position);
  137.  
  138. if(app != null) {
  139.  
  140. TextView titleText = (TextView)v.findViewById(R.id.textView1);
  141. TextView direccionText = (TextView)v.findViewById(R.id.textView2);
  142. TextView valoracionText = (TextView)v.findViewById(R.id.textView3);
  143.  
  144. if(titleText != null) titleText.setText(app.getNombreEmpresa());//populate textView1
  145.  
  146. if (direccionText !=null) direccionText.setText(app.getDireccionEmpresa());//populate textView2
  147. if (valoracionText !=null) valoracionText.setText(String.valueOf(app.getValoracionEmpresa()));
  148.  
  149. final ImageView img = (ImageView)v.findViewById(R.id.imageView1);
  150.  
  151. new AsyncTask<URL, Integer, Long>(){
  152. @Override
  153. protected Long doInBackground(URL... params) {
  154. try {
  155.  
  156. URL url = new URL("http://0.tqn.com/d/webclipart/1/0/5/l/4/floral-icon-5.jpg");
  157.  
  158. HttpGet httpRequest = null;
  159.  
  160. httpRequest = new HttpGet(url.toURI());
  161.  
  162. HttpClient httpclient = new DefaultHttpClient();
  163. HttpResponse response = (HttpResponse) httpclient
  164. .execute(httpRequest);
  165.  
  166. HttpEntity entity = response.getEntity();
  167. BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
  168. InputStream input = b_entity.getContent();
  169.  
  170. Bitmap bitmap = BitmapFactory.decodeStream(input);
  171.  
  172. img.setImageBitmap(bitmap);
  173.  
  174. } catch (Exception ex) {
  175.  
  176. }
  177.  
  178. return null;
  179. }
  180. }.execute();
  181. }
  182. return v;
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement