如何创建像Android的脉冲自定义UI [英] how to create custom UI like pulse in android

查看:200
本文介绍了如何创建像Android的脉冲自定义UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个箱子自定义用户界面类似于脉冲Android应用程序。据我了解,先从我必须首先创建一个自定义按钮标示下面的图片上,如图所示。

I am trying to crate a Custom UI similar to pulse android app. As I understand, to start with I have to first create a custom button as shown on the below image marked.

我的按钮上有一个图像与文字的叠加。我知道这是一个基本的问题,但我面对这个问题,因为我是一个初学者到Android的发展。请你帮助我了解如何使用该走了。

My button has an image and text overlay on it. I know it is a basic question, but I am facing this issue, as I am a beginner to android development. Please do help me to understand how to go with this.

推荐答案

请接受的答案,如果它回答了你的问题。

Please accept the answer if it answered your question.

现在关于与电网整合的一部分:保存上述(RelativeLayout的+的ImageView +的TextView)的例子中的XML内容,到一个新的XML文件,让它成为布局/ grid_item.xml 。结果
添加了独特的 ID 的ImageView 的TextView

Now about the part with grid integration: save the XML content of the example above (RelativeLayout + ImageView + TextView), into a new XML file, let it be layout/grid_item.xml.
Add a unique id for the ImageView and TextView

然后在你的适配器 getView()方法是充气的布局和找到的id的ImageView和TextView的,并设置适当的内容。

Then in the getView() method of your adapter inflate that layout and find the ImageView and TextView by id, and set appropriate content.

请注意,这不是完整的源代码code,但一个基本scheleton应该是这样的:

Note, this is not full source code, but a basic scheleton should look like this:

public View getView(int position, View convertView, ViewGroup parent) {
    ....
    convertView = mInflater.inflate(R.layout.grid_item, null);
    ....

    ImageView myImage=(ImageView)convertView.findViewById(R.id.my_image);
    TextView myTextView=(TextView)convertView.findViewById(R.id.my_textview);

    myImage.setImageResource(...);
    myTextView.setText(...);
    ...

    return convertView
}

这篇关于如何创建像Android的脉冲自定义UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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