خرید بک لینک

Vote count: 0

I am aware that other people have asked this question, but I have looked at other solutions and still can't get it to work.

Adapter code:

    private class CustomTextAndImageAdapter extends ArrayAdapter<String>
    {
        private Context context;
        private Activity activity;
        private ArrayList<String> timeArrayList;
        private ArrayList<Bitmap> weatherIconArrayList;
        private ArrayList<String> descriptionArrayList;
        private ArrayList<String> tempArrayList;
        private ArrayList<String> popArrayList;
        private ArrayList<String> windSpeedArrayList;

        public final void setTimeArrayList(ArrayList<String> timeArrayList)
        {
            this.timeArrayList = timeArrayList;
        }

        public final void setDescriptionArrayList(ArrayList<String> descriptionArrayList)
        {
            this.descriptionArrayList = descriptionArrayList;
        }

        public final void setTempArrayList(ArrayList<String> tempArrayList)
        {
            this.tempArrayList = tempArrayList;
        }

        public final void setPopArrayList(ArrayList<String> popArrayList)
        {
            this.popArrayList = popArrayList;
        }

        public final void setWindSpeedArrayList(ArrayList<String> windSpeedArrayList)
        {
            this.windSpeedArrayList = windSpeedArrayList;
        }

        public final void setWeatherIconArrayList(ArrayList<Bitmap> weatherIconArrayList)
        {
            this.weatherIconArrayList = weatherIconArrayList;
        }

        public CustomTextAndImageAdapter(Context context, Activity activity, int resource)
        {
            super(context, resource);
            this.context = context;
            this.activity = activity;
        }

        @Override
        public View getView(int position, View view, ViewGroup parent)
        {
            Log.d(Constants.LOG_TAG, "getView() method called");
            LayoutInflater inflater = activity.getLayoutInflater();
            View rowView= inflater.inflate(R.layout.itemlistrow, null, false);

            TextView timeTextView = (TextView)rowView.findViewById(R.id.time);
            timeTextView.setText(timeArrayList.get(position));
            Log.d(Constants.LOG_TAG, "Time text view text = " + timeArrayList.get(position));

            ImageView iconImageView = (ImageView) rowView.findViewById(R.id.weatherIcon);
            iconImageView.setImageBitmap(weatherIconArrayList.get(position));

            TextView descriptionTextView = (TextView)rowView.findViewById(R.id.description);
            descriptionTextView.setText(descriptionArrayList.get(position));

            TextView tempTextView = (TextView)rowView.findViewById(R.id.temp);
            tempTextView.setText(tempArrayList.get(position));

            TextView popTextView = (TextView)rowView.findViewById(R.id.pop);
            popTextView.setText(popArrayList.get(position));

            TextView windSpeedTextView = (TextView)rowView.findViewById(R.id.windSpeed);
            windSpeedTextView.setText(windSpeedArrayList.get(position));

            retu rowView;
        }
    }
}

List item layout (itemlistrow.xml:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/time" />

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1">
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/weatherIcon"
                />
        </LinearLayout>
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Suy"
                android:id="@+id/description"
                />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="11 C"
                android:id="@+id/temp"
                />
        </LinearLayout>
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text = "Rain:"
                />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text = "Wind:"
                />
        </LinearLayout>
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id = "@+id/pop"
                />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text = "@+id/windSpeed"
                />
        </LinearLayout>
    </LinearLayout>
    </LinearLayout>

In some of the other solutions, it mentions overriding getCount(). Is this what I am doing wrong? If so, how would I know what to put in for getCount(), as there are multiple different ArrayLists used. Is it a case of picking one of them, as they are all the same length, e.g. timeArrayList.size()?

asked 1 min ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 9 اسفند 1394 ساعت: 14:58

صفحه بندی