私が開発している Android 4.1 アプリでは、検索結果リスト ビューのテキストをサムネイルの右側に表示したいと考えています。xml ファイルを解析して結果を取得します。現在、テキストは画像の下に表示されていますが、画像の右側に表示したいです。
people_search_list.xml
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@android:id/list"
android:layout_width="fill_parent" android:layout_height="0dip"
android:layout_weight="1" android:drawSelectorOnTop="false"
/>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:contentDescription="@string/description"
android:gravity="left"
android:scaleType="fitXY" />
<TextView
android:id="@+id/empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="left"
android:text="" />
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/footer"
style="@android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/prev_10_results"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.14"
android:text="@string/prev_10_results" />
<Button
android:id="@+id/next_10_results"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/next_10_results" />
</LinearLayout>
</ScrollView>
</LinearLayout>
PeopleSearchAdapter.java (これは、xml ファイルから取得した後にコンテンツを表示している場所です)
public PeopleListView (Context context, String itemName, String itemLocation, String image_url, String kudoRank)
{
super (context);
setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(5, 3, 5, 0);
image = new ImageView (context);
Log.v("Image URL: ", image_url);
if(image_url != null && !(image_url.equals("")))
{
try
{
URL url = new URL (image_url);
URLConnection conn = url.openConnection();
conn.connect();
BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
Bitmap bm = BitmapFactory.decodeStream (bis);
bis.close ();
image.setImageBitmap(bm);
}
catch (IOException e)
{
e.printStackTrace();
}
}
else
{
image.setImageResource(R.drawable.no_image);
}
addView (image, params);
name = new TextView (context);
name.setText(itemName);
name.setTextSize(16f);
name.setTextColor(Color.BLACK);
addView(name, params);
kudo_rank = new TextView (context);
kudo_rank.setText(kudoRank);
kudo_rank.setTextSize(16f);
kudo_rank.setTextColor(Color.BLACK);
addView(kudo_rank, params);
location = new TextView (context);
location.setText(itemLocation);
location.setTextSize(16f);
location.setTextColor(Color.BLACK);
addView(location, params);
}
I've attached a screenshot of how the results are being displayed now and just want the three text fields that are displayed below the image right now to be displayed to its right instead.
ありがとう..