Reputation: 3563
I'm trying to implement the Appboy Feedback Fragment into my Android Application and I'm running into so difficulty. I create the Fragment like this:
AppboyFeedbackFragment appboyFeedbackFragment = new AppboyFeedbackFragment();
And when I want to add it to the current Activity I do it like this:
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.add(R.id.settingsParent, appboyFeedbackFragment);
transaction.commit();
But when I do this it tells me appboyFeedbackFragment is not a Fragment. Next I tried casting it to a Fragment since it extends the Fragment class, however that did not work either. I'm not sure how to add the Fragment. I'm new to fragments, so I might be misunderstanding something. Any help would be greatly appreciated, thanks!
Upvotes: 1
Views: 251
Reputation: 573
Here what I did :
public class SendFeedbackActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.send_feedback_layout);
final FragmentManager fragmentManager =getSupportFragmentManager();
AppboyFeedbackFragment appboyFeedbackFragment = (AppboyFeedbackFragment) fragmentManager.findFragmentById(R.id.feedback_fragment);
appboyFeedbackFragment.setFeedbackFinishedListener(new AppboyFeedbackFragment.FeedbackFinishedListener() {
@Override
public void onFeedbackFinished() {
// Pops the top of the back stack and displays the previous fragment
finish();
}
});
}
}
The content of send_feedback_layout is :
<?xml version="1.0" encoding="utf-8"?>
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/feedback_fragment"
android:name="com.appboy.ui.AppboyFeedbackFragment"
xmlns:android="http://schemas.android.com/apk/res/android" />
Upvotes: 1