2

I dread designing UI for Android apps, and I have been searching and trying every possible combination of things to get this the way I want it, but I just cannot seem to get it right.

I want to have a simple Android app that has a text field and a send button next to each other on the bottom of the screen (I already have this correct), and I also want a functional chat area filling the rest of the screen above.

It obviously needs to be scrollable, and I would like to be able to add a new line to the bottom of the chat by doing something like chatBox.add(username, text).

This is the type of view I am looking for:

<bob> my name is bob
<bill> hi bob, my name is bill!
<bob> we are having an awesome conversation, bill
<bill> both of our names start with a b
<bob> how right you are
4

3 に答える 3

3

そんなアプリを作っていました。チャット ウィンドウには listView を使用しました。ListView には stackFromBottom モードがあります。したがって、最後に追加されたメッセージは ListView の下部に表示されます。また、ArrayAdapter を拡張するカスタム アダプターを作成したので、新しいメッセージを簡単に追加できます。

これは良い例です。 listView をアダプターで使用して新しいアイテムを追加する方法です。

于 2013-02-10T09:52:09.433 に答える
2

Leonisdos の言うとおりです。listView を使用する必要があります。Irssi-ConnectBotというアプリをご存知ですか?多くの良い例があるように、そのソース コードを確認する必要があると思います。

Irssi- connectbotの code.google プロジェクト (およびgithub )

于 2013-02-11T12:15:01.617 に答える
0

TextViewaを a でラップしScrollViewます。新しいチャット エントリを追加する場合は、およびで使用append()します。TextViewfullScroll(View.FOCUS_DOWN)ScrollView

チャットが長い場合は、レオニドスのListViewアプローチの方が効率的ですが、これについて言及したいと思います.

于 2013-02-11T12:27:12.917 に答える