-1

I have an activity, this activity name is Game, it's xml file is composed by two views control, first of them it's a TextView called Texto and the second one is a SurfaceView created by me called Juego. The Juego view has an onTouchListener event, and i want to send a text to the control called Texto everytime the user clicks on the control Juego.

I have all the "structure" created but i can't "communicate" from Juego to Texto, every thing i try i get an error.

Thx for help in advance,

U. Busto
  • 194
  • 1
  • 17
  • 1
    Please show the relevant code, what you tried and the errors that resulted. If you give your question more context, you'll get better answers. – NigelK Jan 13 '14 at 11:37
  • check this link i think helpful-http://stackoverflow.com/questions/5779215/androidhow-to-add-a-button-in-surface-view In LinearLayout add TextView add when Surfaceview click Then OnTouch Dynamically create Textview (Add in LinearLayout) – Sanket990 Jan 13 '14 at 11:47

1 Answers1

0

Create a listener such as onViewClick(String text). Create instance of this on your SurfaceView and in constructor get this listener as parameter. Now call this listener wherever you want to update the textView.

In you activity class, implement onViewClick listener and in method do:

public void onViewClick(String text){
 TextTo.setText(text);
}
Bipin Bhandari
  • 2,694
  • 23
  • 38
  • Thx for your help, I am starting studying Android so please let me know your anserws with a bit more detail. I can't find onViewClick listener. – U. Busto Jan 13 '14 at 18:25