gpt4 book ai didi

java - android - 如何在已经膨胀的布局中膨胀 map fragment ?

转载 作者:行者123 更新时间:2023-12-01 22:37:21 25 4
gpt4 key购买 nike

我正在我的 Activity 中创建表布局,在循环中动态添加表行。我想要实现的目标是在每个动态创建的表格行中添加一个 Google map fragment 。

这是我的表格行布局:

<?xml version="1.0" encoding="utf-8">
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl_rowitem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp">
<RelativeLayout
android:id="@+id/inflated_row_relative"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_poi_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/orange"
android:textColor="#ffffff"
android:text="Name"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="@+id/img_snapshot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/tv_poi_name"
android:adjustViewBounds="true"
android:src="@drawable/map_snapshot" />
<TextView
android:id="@+id/tv_poi_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Address"
android:textColor="#fe8301"
android:layout_below="@+id/img_snapshot"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/distance_layout"
android:layout_below="@+id/tv_poi_address" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/distance_icon" />
<TextView
android:id="@+id/tv_poi_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/imageView1"
android:text="Distance"
android:paddingLeft="10dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</RelativeLayout>
</TableRow>

这是我动态创建表行的循环:

final TableLayout tblAddLayout = (TableLayout) findViewById(R.id.tl_menu_pois); TableRow inflateRow = (TableRow) View.inflate(Menu_pois.this, R.layout.menu_pois_rowitem, null);
for (int i=0;i<3;i++){

  View inflate = (TableRow) View.inflate(Menu_pois.this, R.layout.menu_pois_rowitem, >tl_menu_pois);
RelativeLayout inflated_row_relative = (RelativeLayout) >inflate.findViewById(R.id.inflated_row_relative);
inflated_row_relative.setTag(i);
TextView poi_name = (TextView) inflate.findViewById(R.id.tv_poi_name);
TextView poi_address = (TextView) inflate.findViewById(R.id.tv_poi_address);

poi_name.setText("Name");
poi_address.setText("Address");
//set tag for each TableRow
inflate.setTag(i);
//add TableRows to TableLayout
tblAddLayout.addView(inflate);
//set click listener for all TableRows
inflated_row_relative.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Object tag = v.getTag();
String string_tag = tag.toString();
}
});

}

我想在每个表行中显示 Google map ,如下图所示(而不是示例图像,有 map ):

http://goo.gl/9erYB7

有办法实现吗?预先非常感谢您。

最佳答案

我找到了一个在同一个 View 上添加多个 map fragment 的解决方案,按照这个示例,以防有人遇到同样的问题:

http://saadroid.blogspot.gr/2013/06/multiple-maps-in-same-view.html

关于java - android - 如何在已经膨胀的布局中膨胀 map fragment ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26704981/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com