すべて私はRSSフィードからいくつかの画像データを表示したいと思います。私のRSSフィードコードはうまくいきました。フィードから正しく読み込まれましたが、イメージを水平に表示できませんでしたか?私はギャラリーを使ってみましたが、イメージを入れることができませんでしたか?同じことを達成する方法はありますか?水平に表示する?
また、http://www.dev-smart.com/archives/34のリンクを参照してHorizontal ListViewを実装していますが、リストにonClickListenerを実装できません。助けてください。ありがとうございました。
私はギャラリーのためにしようとしたコード..
パブリッククラスImageAdapterはBaseAdapter あなたがgalleryholder.xmlを使用することができます{
int imageBackground;
private List<RSSIteam> objects = null;
private Context context;
public ImageAdapter(Context c)
{
context = c;
TypedArray ta = obtainStyledAttributes(R.styleable.Gallery1);
imageBackground = ta.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 1);
ta.recycle();
}
public ImageAdapter(Context context, int textViewResourceId, List<RSSIteam> objects)
{
super();
this.context = context;
this.objects = objects;
}
@Override
public int getCount()
{
return this.objects.size();
//return pics.length;
}
@Override
public Object getItem(int position)
{
return this.objects.get(position);
//return position;
}
@Override
public long getItemId(int position)
{
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
RSSIteam data = (RSSIteam) getItem(position);
String imageUrl = data.imageurl;
try
{
URL feedImage = new URL(imageUrl);
HttpURLConnection conn= (HttpURLConnection)feedImage.openConnection();
InputStream is = conn.getInputStream();
Bitmap img = BitmapFactory.decodeStream(is);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
ImageView iv = new ImageView(context);
iv.setImageResource(img[position]); //here i am unable to set the image in particular position because it require int type array
iv.setScaleType(ImageView.ScaleType.FIT_XY);
iv.setLayoutParams(new Gallery.LayoutParams(90,70));
iv.setBackgroundResource(imageBackground);
return iv;
}
}
を操作するための完全な助けされるコードの下に、これを見て - あなたの試したコードを投稿してください。 – user370305