Android平板电脑开发-从SQLite数据库自动填充多个非列表视图?

Android平板电脑开发-从SQLite数据库自动填充多个非列表视图?,android,android-layout,android-contentprovider,android-sqlite,xoom,Android,Android Layout,Android Contentprovider,Android Sqlite,Xoom,我正在为android平板电脑开发一个选项卡,它是一个片段,有许多视图组(LinearLayouts),其中包含许多彩色圆形视图,其中有许多与之相关联的数据对象。(见屏幕截图) 消息将从网络传入,并更新与每个圆视图关联的数据对象的数量。当它们出现时,我想将它们添加到SQLite数据库中;当这种情况发生变化时,将自动更新侦听视图组。然后将更新与每个CircleView关联的数据对象的数量和内容 我一直在关注内容提供商、适配器等。。但这些似乎是面向占据整个屏幕的列表视图的,比如在手机上。 问题是,我

我正在为android平板电脑开发一个选项卡,它是一个片段,有许多视图组(LinearLayouts),其中包含许多彩色圆形视图,其中有许多与之相关联的数据对象。(见屏幕截图)

消息将从网络传入,并更新与每个圆视图关联的数据对象的数量。当它们出现时,我想将它们添加到SQLite数据库中;当这种情况发生变化时,将自动更新侦听视图组。然后将更新与每个CircleView关联的数据对象的数量和内容

我一直在关注内容提供商、适配器等。。但这些似乎是面向占据整个屏幕的列表视图的,比如在手机上。 问题是,我如何根据数据库的变化在片段中有效地自动更新这些视图? 我将使用什么机制以及如何使用它们。我已经陷入了一些僵局。(基于我有限的android开发经验)

任何洞察都会很棒!谢谢

设置视图的选项卡片段:

    public class TheoryFragment extends Fragment {


    private ViewGroup theoriesView;
    private HashMap<String, TheoryPlanetView> theoryViewsToAnchors = new HashMap<String, TheoryPlanetView>();
    private GestureDetector gestureDetector;    
    private SimpleCursorAdapter dataAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        theoriesView = (ViewGroup) inflater.inflate(R.layout.theories_activity_vertical,
                container, false);

        setupListeners();

        return theoriesView;
    }

    /**
     * Setups the listeners 
     */
    private void setupListeners() {
        //add listeners to all the draggable planetViews
        // get all the colors and the
        int childCount = theoriesView.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View possibleView = theoriesView.getChildAt(i);
            if( possibleView instanceof TheoryPlanetView ) {
                TheoryPlanetView tv = (TheoryPlanetView) possibleView;
                tv.setOnDragListener(new TargetViewDragListener());

                theoryViewsToAnchors.put(tv.getAnchor(), tv);
            }
        }

        ViewGroup planetColorsView = (FrameLayout)             theoriesView.findViewById(R.id.colors_include);
        // get all the colors and the
        childCount = planetColorsView.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View color = planetColorsView.getChildAt(i);
            color.setOnTouchListener(new CircleViewDefaultTouchListener());
        }
    }

}
公共类TheoryFragment扩展了片段{
私有视图组理论视图;
私有HashMap theoryViewsToAnchors=新HashMap();
私人手势检测器;
私有SimpleCursorAdapter数据适配器;
@凌驾
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
theoriesView=(视图组)充气器。充气(R.layout.theories\u activity\u vertical,
货柜(虚假);;
setupListeners();
回归理论观;
}
/**
*设置侦听器
*/
私有void setupListeners(){
//将侦听器添加到所有可拖动的PlanetView
//得到所有的颜色和颜色
int childCount=theoriesView.getChildCount();
for(int i=0;i

理解这个问题有点困难,但我会使用异步任务

基本上,您希望在后台线程上执行网络或数据库操作。任务完成后,android将自动运行一个方法

onPreexecute()->启动进度条等

doInBackground()->网络/db

onPostExecute()->更新您的UI(在doInBackground完成时调用)

如果这还不够,您还可以查看观察者模式