你如何在膨胀的android的XML布局? [英] How do you inflate an XML layout in android?

查看:103
本文介绍了你如何在膨胀的android的XML布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写的,该程序可以列表视图,为此我已经写了扩展ArrayAdapter,从数据库中填充的每一行的类Android应用程序。当点击列表中的一个项目,它触发的意图,我想列出的项目点击详细另一个类,这样我就可以充气的项目的详细信息视图。现在我只是想抬高1的TextView如下:

I'm writing an android application which starts of as a listview, for which I've written a class that extends ArrayAdapter, populating each row from a database. When an Item in the list is clicked, it fires an intent to another class which I want to list the details of the item clicked, so I can inflate the view with the item details. For now I just want to inflate one TextView as follows.

<TextView 
    android:id="@+id/name"
    android:textColor="#FFFFFF"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
/>

我将如何去写这个类的详细信息页面,只接收意向后,建立自己?我是否需要延长一些重写getView方法?

How would I go about writing the class for a details page which only establishes itself after receiving an intent? Do I need to extend something to override the getView method?

推荐答案

有关膨胀可以使用

public View myView()
{
    View v;
    LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    v = inflater.inflate(R.layout.prob3_layout, null);
    return v;
}

这篇关于你如何在膨胀的android的XML布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆