Hello there,
I'd like to settle an activity with some textviews and a Canvas for
drawing. I'd like to use something like a Fragment for drawing while
keeping the text view for showing info on parent activity.
Currently I've as Parent The activity
public class SpriteAnimationActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction =
fragmentManager.beginTransaction();
Fragment fragment = new DrawingFragment();
fragmentTransaction.add(R.id.drawing_area, fragment);
fragmentTransaction.commit();
}
}
and the DrawingFragment looks like:
public class DrawingFragment extends Fragment {
public DrawingFragment()
{}
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
v_ = new SpriteView(getActivity().getApplicationContext());
}
public View onCreateView()
{
return v_;
}
private View v_;
}
the main xml is where the layout is for the SpriteAnimationActivity:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="*">
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/score" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/high_score" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow>
<fragment
android:id="@+id/drawing_area"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</TableRow>
</TableLayout>
but I get runtime exceptions (Error inflating class)
Any tips on how to use Fragment will be much appreciated.
Thxs
Gurunello
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en