开发者

How Create a View Like the Default Android EditContact View?

Specifically, I'm curious about how they did the phone number entry part, where they can add additional phone numbers fields when the user clicks the little add button. I initially thought that was done with a ListView, and I got a ListView to work, but the ListView scrolls independently of the rest of the screen, which looks bad.

So I was wondering what the best approach for something like that is? Am I on the right track with the ListView and just missing something allowing me keep it from behaving like it's own scrollable container? Perhaps a custom AdapterView or maybe just with a TableLayout dyna开发者_运维百科mically adding rows? I'm just not sure what would work the best.


The Contact editor is fairly hard to read through due to the super-duper overkill modularization of the editor activity. I would think a vertical LinearLayout where you just inflate the new view directly into it with [View.inflate][1] would work; alternatively just call the addView method on the LinearLayout to add the edittext/layout to it.

[1]: http://developer.android.com/reference/android/view/View.html#inflate(android.content.Context, int, android.view.ViewGroup)


The layout file for that activity indicates they are using a ScrollView, wrapped around a LinearLayout. Presumably, when they add another phone number, they are inserting a view in the appropriate spot in their LinearLayout. You are welcome to review the source for the application to find out more details about their implementation.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜