Note that there are some explanatory texts on larger screens.

plurals
  1. POZXing - How can I get the result into an EditText which is also used for manual entry?
    primarykey
    data
    text
    <p>I get good results from ZXing (not embedded), but I can't figure out how to get the result into an EditText that is properly defined in the layout xml and declared in the main class - or elsewhere for that matter. Here's my code:</p> <pre><code>public class main extends Activity implements OnClickListener { EditText edit_text = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); edit_text = (EditText) findViewById(R.id.pn); findViewById(R.id.my_button).setOnClickListener(this); findViewById(R.id.scan_button).setOnClickListener(this); } //end of onCreate </code></pre> <p>The ZXing launch happens here inside the conditional: </p> <pre><code>public void onClick(View arg0) { Button b = (Button)findViewById(R.id.my_button); Button s = (Button)findViewById(R.id.scan_button); if(arg0==s){ s.setClickable(false); IntentIntegrator.initiateScan(this); } if(arg0==b){ b.setClickable(false); findViewById(R.id.pn); CharSequence edit_text_value =edit_text.getText(); itemno = edit_text_value.toString(); InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); new LongRunningGetIO().execute(); } }//end of onClick method - note main class is still open </code></pre> <p>and the obligatory zxing result method at the end, still inside the main class: </p> <pre><code>public void onActivityResult(int requestCode, int resultCode, Intent data) { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); edit_text = (EditText) findViewById(R.id.pn); if (scanResult != null) { String resultStr = ""; resultStr = scanResult.getContents(); edit_text.setText = resultStr; } } }//closes main class </code></pre> <p>layout xml here:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/main_layout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:padding="5dp" &gt; &lt;TextView android:id="@+id/tag_line" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;EditText android:layout_margin="20dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="Enter Item Number" android:id="@+id/pn" /&gt; &lt;TableLayout android:id="@+id/button_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:stretchColumns="*" &gt; &lt;TableRow&gt; &lt;Button android:id="@+id/scan_button" android:text="SCAN" /&gt; &lt;Button android:layout_width="wrap_content" android:id="@+id/my_button" android:text="GET RESULTS" /&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; &lt;EditText android:layout_margin="20dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:minLines="30" android:maxLines="30" android:textSize="18sp" android:editable="false" android:id="@+id/my_edit" /&gt; &lt;WebView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>OK, I've tried everything and searched in places I didn't know existed. Does anyone care to show me what I did wrong??? Sorry for the sloppy code. First Q posted here. Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload