我能有一个列表视图和图像图标与TextView的在Android我能、视图、图标、有一个

2023-09-04 06:37:10 作者:我与闹钟抗衡i

我需要有一个ListView像它具有以下Android应用程序

因为我不能发布图片,这是应该的。

INAGE这边|一些自由文本                 |用户名等

下面是你的任务

任务1>

任务2>

任务1和;任务2是这将是动态拿起从DB

名单

我想有一个TextView的问题是,我只能拿到列表或我甚至试过相对布局在这种情况下,文本视图不是两个任意点的时候,我看到的文字重叠列表

 < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
     机器人:ID =@ + ID / g_tracker_layout
     机器人:方向=垂直
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent>

    < TextView中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
                        机器人:ID =@ + ID /问题1
                        机器人:layout_width =match_parent
                        机器人:layout_height =match_parent
                        机器人:自动链接=所有
                        机器人:文本=@字符串/问题1
                        />
   < ListView的机器人:ID =@ + ID / ListView01
 机器人:layout_width =match_parent
 机器人:layout_height =match_parent/>


< / LinearLayout中>
 

任何帮助指导将是很有益的achiving类似这样的布局

以下是在onCreateMethod()

代码段

 公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);

        的setContentView(R.layout.g_tracker_home);
        this.dh =新TrackerDAO(本);
        LV1 =(ListView控件)findViewById(R.id.ListView01);
        trackerObj = dh.selectAll();
        如果(trackerObj!= NULL){
        名单<字符串>人=新的ArrayList<字符串>();
        对于(跟踪OBJ:trackerObj){
          al.add(obj.getTrackerName());
        }
           lv1.setAdapter(新ArrayAdapter<字符串>(这一点,android.R.layout.simple_list_item_1,AL));
   }
 
Revit软件的 实用的小技巧,提高效率

解决方案

尝试是这样的:

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / g_tracker_layout
    机器人:方向=垂直
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent>
    <的TextView
        机器人:ID =@ + ID /问题1
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_alignParentTop =真
        机器人:自动链接=所有
        机器人:文本=@字符串/问题1/>
    < ListView的机器人:ID =@ + ID / ListView01
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent
        机器人:layout_below =@ ID /问题1/>
< / RelativeLayout的>
 

       

我甚至试过相对布局在这种情况下,我看到的文字重叠

  

这是非常好的。之后你会得到一定的专业知识,你将看到 RelativeLayout的是最好的布局方案之一。在这个简单的情况下,你可以使用的LinearLayout 过,但是当事情开始变得复杂,最好使用 RelativeLayout的这是真正灵活,可以让你减少嵌套元素的需求。

I need to have a listview like it is having for the following android application

Since I cannot post the image this is how it should be

INAGE Over here | Some Free text | User name etc

Here is your task

Task 1 >

Task 2 >

Task 1 & Task 2 are the list which would be dynamically picked up from the DB

I am trying to have a list with a textview the problem is that I can only get the List or the text view not both any point of time I have even tried relative layout in that case i see the text overlapping

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/g_tracker_layout" 
     android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">  

    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
                        android:id="@+id/question1"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:autoLink="all"
                        android:text="@string/question1"
                        /> 
   <ListView android:id="@+id/ListView01"
 android:layout_width="match_parent"
 android:layout_height="match_parent" />


</LinearLayout>

Any help guidance would be really helpful in achiving the layout similar to this

Following is the snippet in the onCreateMethod()

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.g_tracker_home); 
        this.dh = new TrackerDAO(this); 
        lv1=(ListView)findViewById(R.id.ListView01); 
        trackerObj = dh.selectAll();
        if(trackerObj!=null) {
        List<String> al = new ArrayList<String>();
        for(Tracker obj : trackerObj ){
          al.add(obj.getTrackerName());
        }
           lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , al));
   }

解决方案

Try something like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/g_tracker_layout" 
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">  
    <TextView
        android:id="@+id/question1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:autoLink="all"
        android:text="@string/question1"/>
    <ListView android:id="@+id/ListView01"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/question1"/>
</RelativeLayout>

I have even tried relative layout in that case i see the text overlapping

That's really nice. After you get some expertise, you will see that RelativeLayout is one of the best layout schemes. In this simple case you could use LinearLayout too, but when things start getting complex, it's better to use RelativeLayout which is really flexible and will allow you to reduce the need of nest elements.

 
精彩推荐
图片推荐