Pro Android 2: What are getTextView () and registerMenu ()?

Listing 3-33 in the famous Pro Android 2 book (the source code can be found here ) refers to two functions, of which definitions, which I could not find either in the Android SDK, or in all in the book itself:

  • getTextView ()
  • registerMenu ()

What are these features and where can I find them?

+1
source share
2 answers
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Helloe, Android. Say Hello"); setContentView(tv); registerForContextMenu(tv); } 

fix the problem of those methods that do not exist.

And not a single book that I read on Android has typos, missing bits, etc.

PS. The menu will be the menu that appears when you click on "TextView."

+1
source

If you want to add ContextMenu to the TextView from your XML layout, you can use this:

 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView tv = (TextView)findViewById(R.id.textViewId); registerForContextMenu(tv); } 
0
source

All Articles