在 Android 的用户界面中显示数据

发布于 2024-10-21 08:33:04 字数 638 浏览 2 评论 0原文

我正在尝试创建一个简单的 Android 应用程序。我是 Android 和 java 新手。我创建了一个简单的界面,用户可以通过该界面登录到应用程序。

现在我想添加一个用户界面,用户可以在其中存储一些详细信息。
例如。信用卡详细信息。

UI 应该具有多行和多列。用户在其中存储他的多个信用卡详细信息。用户界面有一个按钮(添加新卡按钮)。用户可以单击该按钮并添加新卡详细信息。 UI 应立即显示新添加的条目。 (此应用程序将有多个用户。)我所做的列表是:

  1. 我创建了 ccdetails 表(在 dbadapter.java 中)
  2. 我编写了插入查询。

我要做的是

  1. 编写查询来向用户显示 ccdetails。(但我自己可以做到这一点)
  2. 在 UI 中向用户显示这些 ccdetails(我已经在上面给出了 UI 的详细信息。)

我无法执行第二部分。我只是不知道如何为此编写java文件、xml文件。我不知道如何在 UI 中显示用户的详细信息。为此我必须在 dbadapter.java 文件中进行哪些更改。

任何人都可以向我提供一个资源,我可以在其中获得几乎类似情况的源代码或您认为合适的任何其他内容。提前致谢。 (我在win 7机器上使用eclipse。)

I am trying to create a simple android application. I am new to Android and java. I have created a simple interface by which user can log in to the application.

Now I want to add a UI in which user can store some details.

eg. Credit card details.

The UI should have multiple rows and columns. In which the user stores his multiple credit card details. The UI have a button (add new card button.) User can click on that button and add a new card details. The UI should immediately show the new added entry. (This application will have multiple users.) List of what I have done is :

  1. I have created ccdetails table(in dbadapter.java)
  2. I have written the insert query.

What I have to do is

  1. Write query to show users ccdetails.(but I can do this myself)
  2. Showing those ccdetails in a UI to the user(I have given the details of the UI above.)

I am unable to do this second part. I just don't have any idea how to write the java file, xml file for this. I dont know how to show the details of the user in UI. What changes I have to do in dbadapter.java file for this.

Can anybody please provide me a resource where I can get source code for almost similar situation or any other thing that you think appropriate. Thanks in advance. (I am using eclipse in win 7 machine.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

软甜啾 2024-10-28 08:33:05

ListActivityCursorAdapter 结合使用(

此外,完成记事本示例也会有所帮助。

Use a ListActivity with a CursorAdapter (example).

Also, it would help to work through the notepad example.

就是爱搞怪 2024-10-28 08:33:04

Android 活动布局是在名为 res/layout/ 的文件夹中以 XML 形式定义的。定义所需的布局后,您可以

setContentView(R.layout.my_layout);

在 Activity 的 onCreate 函数中调用。您可以在活动中获取名为 views 的布局对象的引用,并根据需要操作它们以显示数据或您想要的任何内容,方法是使用

Button myButton = (Button) findViewById(R.id.my_button)

For your UI you would need a ListView按钮

ListViews 内的数据通过 Adapter 进行管理。

阅读一些 Hello World 教程,尤其是其他答案中提到的记事本教程。

Android activity layouts are defined in XML inside a folder called res/layout/. After you have defined the layout that you need you call

setContentView(R.layout.my_layout);

inside your activity's onCreate function. You can obtain references for your layout objects called views inside your activity and manipulate them as needed to display data or whatever you want there by using

Button myButton = (Button) findViewById(R.id.my_button)

For your UI you would need a ListView and a Button.

Data inside ListViews is managed through an Adapter.

Go through some Hello World tutorials and especially the Notepad tutorial as mentioned in other answers.

心舞飞扬 2024-10-28 08:33:04

您可以使用RelativeLayout 来轻松创建此类布局。

您可以参考这个链接,它描述了不同类型的布局。

You may go for RelativeLayout for creating these kind of layouts easily.

You may refer this link which describes different type of layouts.

甜味拾荒者 2024-10-28 08:33:04

请参阅http://developer.android.com/resources/tutorials/hello-world。 html

onClick按钮,调用返回数据的方法,然后在相应的小部件中设置值。

Refer http://developer.android.com/resources/tutorials/hello-world.html

onClick of your button,call the method which returns data and then set the values in the corresponding widgets.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文