Xperia arc choppy galereyasi

Men Gallery dan foydalanishni talab qiladigan ilova qilmoqdaman. Muammo shundaki, Gallery chindan ham chopib. Mening kodim Android-ni taqdim etadigan kod o'rniga juda o'xshaydi, lekin faqat ImageAdapter ega bo'lishdan ko'ra, ImageView kodini qaytarishdan ko'ra, LinearLayout kodi>, chunki rasmning ostidagi matn kerak. Har qanday taklif bormi?

Mana mening kodim:

package org.example.gallery;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class GalleryTestActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Gallery gallery = (Gallery) this.findViewById(R.id.gallery);
    gallery.setAdapter(new ItemAdapter(this));

    gallery.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v,
            int position, long id) {
        Toast.makeText(GalleryTestActivity.this, "" + position,
            Toast.LENGTH_SHORT).show();
        }
    });
    }

    public class ItemAdapter extends BaseAdapter {
    private Context mContext;

    private final Integer[] mImageIds = { R.drawable.sample_1,
        R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4,
        R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7,
        R.drawable.sample_8 };

    private final String[] mStringIds = { "1-pc. Chicken with Rice",
        "2-pc. Chicken with Rice", "Tower Burger", "Bucket", "Barrel",
        "Chicken Fillet", "Chicken burger", "Another Chicken Burger" };

    public ItemAdapter(Context c) {
        this.mContext = c;
    }

    public int getCount() {
        return mImageIds.length;
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        LinearLayout l = new LinearLayout(this.mContext);
        l.setOrientation(LinearLayout.VERTICAL);

        ImageView iv = new ImageView(this.mContext);
        iv.setImageResource(mImageIds[position]);
        iv.setScaleType(ImageView.ScaleType.FIT_CENTER);

        TextView tv = new TextView(this.mContext);
        tv.setText(mStringIds[position]);
        tv.setTextSize(20);
        tv.setTextColor(Color.RED);
        tv.setGravity(Gravity.CENTER_HORIZONTAL);

        l.addView(iv);
        l.addView(tv);

        return l;
    }
    }
}
0
ularni bir vaqtning o'zida xotiraga sola olasizmi? #onResume() da ularni oldindan yuklashni o'ylab ko'ring (va #onPause() da Drawable: s-ni chiqaring).
qo'shib qo'ydi muallif Jens, manba
bu tasvirlar qanchalik katta (piksellarda)?
qo'shib qo'ydi muallif Selvin, manba
ular 400x400px atrofidagi png fayllari
qo'shib qo'ydi muallif cesar, manba

1 javoblar

ViewHolderdan foydalaning (shuning uchun u har qanday getView chaqiruvida (fikrlarni qayta ishlash) ko'rinishini shaffollamaydi/yaratmaydi) bu namunadagi kabi:

http://developer.android .com/resurslari/namunalari/ApiDemos/src/com/example/android/apis/view/List14.html

EDIT:

       static class ViewHolder {
            TextView tv;
            ImageView iv;
        }

   public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
        if(convertView == null){

        LinearLayout l = new LinearLayout(this.mContext);
        l.setOrientation(LinearLayout.VERTICAL);

        ImageView iv = new ImageView(this.mContext);

        iv.setScaleType(ImageView.ScaleType.FIT_CENTER);

        TextView tv = new TextView(this.mContext);

        tv.setTextSize(20);
        tv.setTextColor(Color.RED);
        tv.setGravity(Gravity.CENTER_HORIZONTAL);

        l.addView(iv);
        l.addView(tv);
        convertView = l;
        holder = new ViewHolder();
        holder.tv = tv;
        holder.iv = iv;

        } else {
        holder = (ViewHolder)convertView.getTag();
    }
    holder.tv.setText(mStringIds[position]);
    holder.iv.setImageResource(mImageIds[position]);

        return convertView;
    }
1
qo'shib qo'ydi
Men buni qildim; Men buning uchun xml formatini yaratdim, lekin u hali ham chopib ketgan. Men boshlovchining ekrani silliq bo'lganligi sababli u 8 ta rasmni ishlasa bo'ladi. Kamroq rasmlarni ishlatishga harakat qilaman.
qo'shib qo'ydi muallif cesar, manba