대화 목록과 메신저 UI가 있습니다. 원하는 목록 : 대화 목록의 항목을 클릭하면 메신저 UI가 해당 대화 메시지와 함께 나타납니다. 시도 : 지금까지이 코드를 코딩하지 않았으므로 아이디어를 찾았습니다. 각 메시지를 즉시 DB에 저장하는 것이 좋으며 대화간에 이동할 때 적절한 메시지를 삭제할 수 있습니까?대화를 탐색하고 이전 메시지를 봅니다.
답변
최근에 비슷한 일을했습니다. 이를 달성하기 위해 TabHost를 사용했습니다. FrameLayout은 TextView로 변환 될 수있는 각각의 FrameLayout과 연관되어 있습니다. TextView는 원하는대로 가정합니다.
이 접근법은 장애가 있습니다. 현재 열린 탭의보기 (이 경우 TextView)에 액세스 할 수 있습니다. 비활성 탭에 텍스트를 추가 할 계획이 없다면 TabHost가 각 탭의 이전 메시지를 처리 할 때 더 이상 수행 할 필요가 없습니다. 예를 들어 비활성 탭에 메시지를 추가하려면 메시지를 대기열에 먼저 저장하고 탭이 활성화 된 후에는 OnTabChangedListener 이벤트로 메시지를 처리해야합니다.
final TabHost th = (TabHost) (this.findViewById(android.R.id.tabhost));
th.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(final String tabId) {
// Here you do the stuff you need. tabId is the name (also called Indicator) of the activated tab
}
});
또한 제어 알고 있어야합니다 : 당신이 tabchange의 이벤트를 처리해야하는 경우, 당신이 뭔가를해야
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/TabContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="99"
android:orientation="vertical">
<TabHost
android:id="@+android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/TabLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- This makes your TabHost horizontally scrollable if it reaches a certain number of tabs -->
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none">
<TabWidget
android:id="@+android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TabWidget>
</HorizontalScrollView>
<!-- You may also want to make this FrameLayour vertically scrollable -->
<FrameLayout
android:id="@+android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"></FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
다음 TabHost 구조에 대한 내 정의의
각 탭의 버퍼 즉, 제어하지 않고 커지면 앱이 무책임하기 시작할 수있는 것처럼 각 탭에 X 개 이상의 메시지가없는 것을 제어합니다. 그들이 나에게했던 것처럼
이 링크는 도움이 될 나는이 부분을 프로그래밍 할 때 :
https://gist.github.com/jerolimov/618086
http://androidituts.com/android-tab-layout-example/
http://learnandroideasily.blogspot.com.es/2013/07/android-tabwidget-example.html
을DB에 conv를 저장하는 것이 좋습니다. 데이터를 직렬화해야합니다. 또는 파일을 사용하여 저장해야합니다.? 또는 구분 기호를 사용하여 임의 액세스 권한을 가질 수 있습니다.