Dank Meme Bro further Question

0 Ananth Venkatesh · August 28, 2015
Want to integrate your gesture lesson further into this app.
How can I OnFlick on my MainActivity and get the text on my Meme?
I mean how do I send a signal to the Fragment from the MainActivity?

Post a Reply

Replies

Oldest  Newest  Rating
0 Dol Lod · August 31, 2015
What signal are you looking for? You could create a variable to hold the fragment when it is created and modify it through there.

Explain a bit more about what you are trying to do.

Think about where the work makes the most sense to do:

Is it better in the fragment or the main activity?

Where should the signal be received, the main activity or the fragment?
0 Ananth Venkatesh · September 2, 2015
I did this in my topfragment.

public void onFlick(){
activityCommander.createMeme(topMemeLine.getText().toString(),bottomMemeLine.getText().toString());
}

And this on my MainActivity

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
topfragment topline = (topfragment) getSupportFragmentManager().findFragmentById(R.id.fragment);
topline.onFlick();
return true;
}

@Override
public boolean onTouchEvent(MotionEvent event) {
this.gestureDetector.onTouchEvent(event);
return super.onTouchEvent(event);
}

But app crashes as soon as I flick. Can somebody help.
  • 1

Java / Android Development

107,214 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator