Thursday 15 August 2013

java - The method getText() is undefined for the type ListView -


I am trying to apply a popup window where you type text and add this list to the review but I The following error is getting:

The method for type getText () is undefined:

  package com.mkyong.android; Import android App Import android.app.AlertDialog; Import android.content.Context; Import android.content.DialogInterface; Importroid.os.Bundle; Import android.view.LayoutInflater; Import android.view.View; Import android.view.View.OnClickListener; Import android.widget.Button; Import android.widget.EditText; Import android.widget.ListView; Public class extends the main activity (last REFERENCES = this; private Button, Private list view results; public Crate zero (bundle saved Instansstet) {Suprknkret (saved Instensstet); setContentView (R.layout.main ); // result = component main.xml buttons (button) FindViewById (RkidkbuttonPrompt); = (ListView) searches Vivibiaiaidi (Arkaidklistiwu 1); // button listener add ButtonksetOnClickListener (new OnClickListener () {@Override Public Zero onClick (see Switch to arg0) {// get prompts.xml scene LayoutInflater Li = LayoutInflater.from (reference); see promptsView = li.inflate (Free. Layout.prompts, NULL); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder (reference); // set alertdialog builder alertDialogBuilder.setView (promptsView prompts.xml); final ListView userInput = (ListView) promptsView .findViewById (R.id .ListTitleDialogUserInput); // set dialog message alertDialogBuilder .setCancelable (wrong) Create .setPositiveButton ( " ", New DialogInterface.OnClickListener () {Public Zero onClick (DialogInterface Dialog, Integer ID) {// Get user input and set it result Results // text edit result.setText (userInp) Ut.getText ());}}) .setNegativeButton ("Cancel", New DialogInterface.OnClickListener () {Public Zero onClick (DialogInterface Dialog, Integer ID) {dialog.cancel ();}}); // Alert Dialog Warning Dialog = WarningDialogbilder. Create (); // show it alert dialogue.show (); }}); }}   

Thanks for your help

EDIT: Code for prompts.xml where ListTitleDialogUserInput is defined;

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: id = "@ + id / layout_root" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" android: orientation = "Vertical" & gt; & Lt; TextView android: id = "@ + id / textView1" Android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" android: text = "List Title:" Android: textAppearance = "? Android: attr / textAppearanceLarge" / & gt ; & Lt; EditText Android: id = "@ + id / listTitleDialogUserInput" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" & gt; & Lt; Requestfocus / & gt; & Lt; / EditText> & Lt; / LinearLayout & gt; << Code>   

You can not enter text directly in the list -

Insert a text-compatible view such as textview within your list view, and call setText () on it.

If you really want a list view that can directly display text, you have to create your own subclass, which extends the ListView and spells some strange overlays or replacements so that you can send it directly to the text Can display on.

No comments:

Post a Comment