Adapter to attach views to the BeyondarObject. More...
Public Member Functions | |
BeyondarViewAdapter (Context context) | |
abstract View | getView (BeyondarObject beyondarObject, View recycledView, ViewGroup parent) |
Override this method to create your own views from the BeyondarObject. More... | |
Protected Member Functions | |
Context | getContext () |
Get Context. More... | |
void | setPosition (Point2 position) |
Set the screen position of the view. More... | |
Adapter to attach views to the BeyondarObject.
This is an example of how to use the adapter:
private class CustomBeyondarViewAdapter extends BeyondarViewAdapter {
LayoutInflater inflater;
public CustomBeyondarViewAdapter(Context context) {
super(context);
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public View getView(BeyondarObject beyondarObject, View recycledView, ViewGroup parent) {
if (!showViewOn.contains(beyondarObject)) {
return null;
}
if (recycledView == null) {
recycledView = inflater.inflate(R.layout.beyondar_object_view, null);
}
TextView textView = (TextView) recycledView.findViewById(R.id.titleTextView);
textView.setText(beyondarObject.getName());
Button button = (Button) recycledView.findViewById(R.id.button);
button.setOnClickListener(AttachViewToGeoObjectActivity.this);
// Once the view is ready we specify the position
setPosition(beyondarObject.getScreenPositionTopRight());
return recycledView;
}
}
Then when the adapter is ready we can set it in the BeyondarFragment:
CustomBeyondarViewAdapter customBeyondarViewAdapter = new CustomBeyondarViewAdapter(this); mBeyondarFragment.setBeyondarViewAdapter(customBeyondarViewAdapter);
|
protected |
Get Context.
|
abstract |
Override this method to create your own views from the BeyondarObject.
The usage of this adapter is very similar to the ListAdapter.
private class CustomBeyondarViewAdapter extends BeyondarViewAdapter {
LayoutInflater inflater;
public CustomBeyondarViewAdapter(Context context) {
super(context);
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public View getView(BeyondarObject beyondarObject, View recycledView, ViewGroup parent) {
if (!showViewOn.contains(beyondarObject)) {
return null;
}
if (recycledView == null) {
recycledView = inflater.inflate(R.layout.beyondar_object_view, null);
}
TextView textView = (TextView) recycledView.findViewById(R.id.titleTextView);
textView.setText(beyondarObject.getName());
Button button = (Button) recycledView.findViewById(R.id.button);
button.setOnClickListener(AttachViewToGeoObjectActivity.this);
// Once the view is ready we specify the position
setPosition(beyondarObject.getScreenPositionTopRight());
return recycledView;
}
}
beyondarObject | |
recycledView | |
parent |
|
protected |
Set the screen position of the view.
When the view is created use this method to specify the position on the screen.
position |