如何在inflater布局中设置textview以获得贴图标记?

时间:2013-04-18 11:04:43

标签: android android-listview layout-inflater

我是android的新手

我在膨胀布局中面临设置关闭标记的问题

如何在inflater中设置关闭标记?如何实现这个?

任何人帮助我。

我试试这个..

  LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  viewList = Nexttopic.this.getLayoutInflater().inflate(R.layout.activity_nexttopic, null);
  dialogMarketList = new Dialog(Nexttopic.this);
  dialogMarketList.requestWindowFeature(Window.FEATURE_NO_TITLE);
  dialogMarketList.setTitle("TOPICS");
  dialogMarketList.setContentView(viewList);
  dialogMarketList.show();     
  lvForDialog = (ListView) viewList.findViewById(R.id.List_view);
  lvForDialog.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
  ArrayAdapter<String> adapter = (new ArrayAdapter<String>(Nexttopic.this, R.layout.row_topic, R.id.child_row,tnamelist));
  lvForDialog.setAdapter(adapter);  

活性-nexttopic.xml

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Nexttopic" >
<ListView
    android1:id="@+id/List_view"
    android1:layout_width="match_parent"
    android1:layout_height="330dp"
    android1:layout_centerHorizontal="true"
    android1:layout_centerVertical="true"
     android:background="@drawable/bg">
</ListView>
</RelativeLayout>

row_topic.xml

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent" 
           android:weightSum="1">
 <TextView 
 android:id="@+id/c_txt"
 android:layout_width="fill_parent"
 android:layout_height="50dp"
 android:text="X"
 android:textSize="25dp"
 android:gravity="right"/>
<TextView
android:id="@+id/child_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/c_txt"
android:layout_marginTop="27dp"
android:background="@drawable/bg"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingLeft="6dip"
android:textColor="@android:color/white" />
</RelativeLayout>

它的出现就像上面列表中的每个文本视图一样显示....

1 个答案:

答案 0 :(得分:0)

您应该将您的关闭标记放在activity-nexttopic.xml布局而不是row_topic.xml中。您在list_topic.xml中放置的任何内容都将在Listview中的每一行重复。