开发者

Showing data in User Interface in Android

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 ca开发者_Go百科rd 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.)


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.


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

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


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.


Use a ListActivity with a CursorAdapter (example).

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜