在我正在开发的 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.
谢谢..