I am developing for an android tablet and I have one tab which is a fragment that has a number of ViewGroups (LinearLayouts) containing a number of colored circle views - which have a number dataobjects associated with them. (see screen shot)
Messages will come in from the network and update the number of dataobjects associated with each circle view. When they come in i want to add them to an SQLite DB; and when that changes automatically update listening ViewGroups. Which will then update the number and content of the dataobjects associated with each CircleView.
I have been looking at content providers, adapters etc.. but these seem to be oriented for listviews that take up the entire screen such as on a phone. Question is how do I efficiently update these views automatically within my fragment based on DB changes? What mechanisms would i use and how would i use them. I have been coming to a number of deadends. (based on my limited android dev exp)
Any insight would be great! Thanks
Tab fragment where i set up my views:
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());
}
}
}