Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>this is a working example</p> <pre><code>import java.io.ByteArrayInputStream; import java.util.List; import org.json.JSONException; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; public class StockQuoteAdapter extends ArrayAdapter { private final Activity activity; private final List stocks; public StockQuoteAdapter(Activity activity, List objects) { super(activity, R.layout.movie , objects); this.activity = activity; this.stocks = objects; } @Override public View getView(int position, View convertView, ViewGroup parent) { View rowView = convertView; StockQuoteView sqView = null; if(rowView == null) { // Get a new instance of the row layout view LayoutInflater inflater = activity.getLayoutInflater(); rowView = inflater.inflate(R.layout.stock, null); // Hold the view objects in an object, // so they don't need to be re-fetched sqView = new StockQuoteView(); sqView.ticker = (TextView) rowView.findViewById(R.id.ticker_symbol); sqView.quote = (TextView) rowView.findViewById(R.id.ticker_price); sqView.time = (TextView) rowView.findViewById(R.id.showtimelist); sqView.img = (ImageView) rowView.findViewById(R.id.Image); sqView.btn = (Button) rowView.findViewById(R.id.lmbtn); sqView.ll = (LinearLayout) rowView.findViewById(R.id.LinearLayout02); // Cache the view objects in the tag, // so they can be re-accessed later rowView.setTag(sqView); } else { sqView = (StockQuoteView) rowView.getTag(); } // Transfer the stock data from the data object // to the view objects final StockQuote currentStock = (StockQuote) stocks.get(position); sqView.ticker.setText(currentStock.getTickerSymbol()); sqView.quote.setText(currentStock.getT_name()); sqView.time.setText(currentStock.getTime()); try{ byte[] bb = currentStock.getBb(); ByteArrayInputStream imageStream = new ByteArrayInputStream( bb); Bitmap theImage = BitmapFactory .decodeStream(imageStream); Drawable d = new BitmapDrawable(theImage); sqView.img.setBackgroundDrawable(d); }catch (Exception e) { // TODO: handle exception e.printStackTrace(); } sqView.ll.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); return rowView; } protected static class StockQuoteView { protected TextView ticker; protected TextView quote; protected TextView time; protected ImageView img; protected Button btn; protected LinearLayout ll; } } </code></pre> <p>add to activity</p> <pre><code>StockQuoteAdapter aa = new StockQuoteAdapter(this, stocks); </code></pre> <p>the stock.xml is </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; - &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:padding="6dip" android:layout_height="match_parent" android:orientation="horizontal"&gt; - &lt;LinearLayout android:id="@+id/LinearLayout02" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"&gt; &lt;ImageView android:id="@+id/Image" android:layout_height="80px" android:layout_width="60px" android:layout_margin="15px" /&gt; - &lt;LinearLayout android:id="@+id/LinearLayout01" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/ticker_symbol" android:textColor="#000000" android:textStyle="bold" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/ticker_price" android:textColor="#000000" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/showtimelist" android:textColor="#000000" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload