Android :: Android - Avoiding Conflict Of Setting Text Field Values

Nov 17, 2010

I'm writing an Android application that allows a user to maintain a list of products. In the EnterProductData activity, the user can enter information about the product into form fields, which will then save the info to a SQLite DB. The EnterProductData activity also allows the user to initiate a barcode scan via the Barcode Scanner app in order to capture the UPC code. The problem I'm facing is trying to set the value of the UPC text field in onActivityResult() once the barcode scan activity is complete and returns the value.

What is ending up happening is my onResume() method is calling a function (populateFields()) that sets the values of the text fields to whatever is currently saved in the DB. And this seems to be happening after onActivityResult() is called. This means the scanned UPC is set as the text field value, only for an empty value to be set to it immediately after. The line of code to blame is commented with asterisks next to it. I imagine that if I immediately save the scanned UPC to the DB in the onActivityResult() method, I can avoid this problem, but that doesn't seem to be the best practice, in my opinion. Can someone advise me on what I should do?

EnterProductData.java
public class EnterProductData extends Activity {
private Button mScanButton;
private EditText mUPC;
private Button mSaveButton;
private Long mRowId;
private DbAdapter mDbHelper;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mDbHelper = new DbAdapter(this);
mDbHelper.open();
setContentView(R.layout.enter_product_data);
mUPC = (EditText) findViewById(R.id.UPC);
mScanButton = (Button) findViewById(R.id.scanButton);
mSaveButton = (Button) findViewById(R.id.saveButton);

mRowId = (savedInstanceState == null) ? null :
(Long) savedInstanceState.getSerializable(DbAdapter.KEY_PRODUCT_ROWID);
if (mRowId == null) {
Bundle extras = getIntent().getExtras();
mRowId = extras != null ? extras.getLong(DbAdapter.KEY_PRODUCT_ROWID): null;}
populateFields();
mScanButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
IntentIntegrator.initiateScan(EnterProductData.this);}});
mSaveButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
setResult(RESULT_OK);
finish();}});
}private void populateFields() {
if (mRowId != null) {
Cursor product = mDbHelper.fetchProduct(mRowId);
startManagingCursor(product);
mUPC.setText(product.getString(
product.getColumnIndexOrThrow(DbAdapter.KEY_UPC))); //******}
}@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
saveState();
outState.putSerializable(DbAdapter.KEY_PRODUCT_ROWID, mRowId);
}@Override
protected void onPause() {
super.onPause();
saveState();
}@Override
protected void onResume() {
super.onResume();
populateFields();
}private void saveState() {String upc= mUPC.getText().toString();
if (mRowId == null) {
long id = mDbHelper.createProduct(mRowId, UPC);
if (id > 0) mRowId = id;
}} else {mDbHelper.updateProduct(mRowId, UPC);
}}protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(requestCode) {
case IntentIntegrator.REQUEST_CODE: {
if (resultCode != RESULT_CANCELED) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (scanResult != null) {
String upc = scanResult.getContents();
mUPC.setText(upc);
}}break;
}}}}

Android :: Android - Avoiding Conflict of Setting Text Field Values


Android :: WebView With Theme Doesn't Show Focused Text Field Values

Apr 4, 2009

I have encountered a problem with focused text fields in a WebView not showing entered text values.As long as a WebView text field has focus it will not show text or even the blinking cursor.You can select and highlight the text or unfocus the field to see it, but when it gains focus it will not show the text as if the foreground color of the text is white.The simplest code to demonstrate this is below.With the setTheme using a Light background, try typing values into the Email text field to notice that the text is not visible when the field is focused.

View 4 Replies View Related

Android :: Setting Values And Display Text In Android Spinner

May 31, 2010

I need help in setting up value and display text in spinner. As per now I am populating my spinner by array adapter e.g. mySpinner.setAdapter(myAdapter);

And as far as I know after doing this the display text and the value of spinner at same position is same. The other attribute that I can get from spinner is the position on the item. Now in my case I want to make spinner like the drop down box, which we have in .NET. Which holds a text and value. Where as text is displayed and value is at back end. So if I change drop down box , I can either use its selected text or value. But its not happening in android spinner case.

For Example:

Text Value
Cat 10
Mountain 5
Stone 9
Fish 14
River 13
Loin 17

So from above array I am only displaying non-living objects text, and what I want is that when user select them I get there value i.e. like when Mountain selected I get 5. I hope this example made my question a bit more clear.

View 2 Replies View Related

Android :: Setting UI Preference Summary Field To Value

Sep 30, 2010

New to Android, I have some code when the user changes a preference I update the Summary field in the UI preference to be the value they entered. However, when the preference activity is created I'd like to set the Summary fields to be the values in the corresponding preferences.
Please advise. Thanks.

public class MyPreferenceActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference);
SharedPreferences sp = getPreferenceScreen().getSharedPreferences();
sp.registerOnSharedPreferenceChangeListener(this);
} public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Preference pref = findPreference(key); if (pref instanceof EditTextPreference) { EditTextPreference etp = (EditTextPreference) pref; pref.setSummary(etp.getText());
} } }

View 1 Replies View Related

Android :: Custom Contacts Field With A Set List Of Values And Contacts Lookup Performance

May 28, 2010

I'm pretty sure it's not viable to do what I'd like to based on some initial research, but I figured it couldn't hurt to ask the community of experts here in case someone knows a way.

I'd like to create a custom field for contacts that the user is able to edit from the main Contacts app; however, the user should only be allowed to select from a list of four specific values. A short list of string values would be ideal, but an int with a min/max range would suffice.

I'm interested in knowing if it's possible either way, but also wondering if it make sense to go this route performance wise. More specifically, would it be better to look up a contact (based on a phone number) each time a call or SMS message is received or better to store my own set of data (consisting of name, numbers, and the custom field) and just syncing contact info in a thread every so often? Or syncing contacts the first time the app is run and then registering for changes using ContentObserver?

View 1 Replies View Related

Android :: DIP Scale And Setting Values In Code

Jul 7, 2009

I have read about using a 'dip' scale rather than just px, this is straightforward to implement in XML. But how do I adjust values accordingly in the java code? For example:

tv.setTextSize(20)

will result in text of size 20 px right? What's the quickest way of making this 20 dip, other than adding a resource?

View 3 Replies View Related

Android :: Inserting Images In Text Field Along With The Text

Aug 7, 2009

I want to add Image to Text field, at the same time i want to write text

under that image( want to describe about the image ) in the same text field. And the image

should be provided with ZOOOM_IN and ZOOM_OUT options, for the user to view.

View 2 Replies View Related

Android :: Licensing - Setting Server Response Values Per Application

Aug 5, 2010

So I've just published my first paid app to the Market and I used the new LVL with the default ServerManagedPolicy. On working through the docs and getting it set up I noted the references to the server response extras VT, GT, GR & UT, and the impression I got from quotes such as "a typical value would be 5 or more days.", "a typical value would be "10" or higher." etc., was that we would have some way of setting these server response values per app when we upload them to the Market. Either I'm missing something, or there does not seem to be a way to set these in the Developer Console that I can see? If we can't set these, it's not really a 'managed' policy at all, but a random 'whatever the server decides to respond with' policy, particularly given the vagueness of the documentation.

I really hate phone home licensing, and am only using it because it seems to be the only option to combat Android piracy. Ideally I want to just check once when the app is first launched, once a day or two later to check they didn't return it, then cache that for 6 months (forever?) to minimize disruption to my users. Is this kind of thing possible with the ServerManagedPolicy or do I have the wrong end of the stick about the 'management' features and have to roll my own? On a side note, if I can't buy my own app, how can I test my licensing is working in the wild? I got several 'NOT_LICENSED' responses in testing even when I set it to return 'LICENSED' in the console, so I'm not 100% convinced of its stability and want to actually see how well it works outside the testing environment, but apparently can't buy my own app to do so!

View 4 Replies View Related

Android : Put All Code Relating To Creating Time - Date Dialogs Setting Values

Sep 24, 2010

I'm currently learning android and java, and I am having some issues with importing a java file.

I am working with the time and date example in the android api demos, and I want to put all the code relating to creating the time and date dialogs setting the values etc into a separate java file, and in my main java file run when the application starts, just declare the buttons and onclick events.

What is the best way to do this? Do I need to put all the code inside a class(that extends activity) or method? How do I use this inside my main class. Code...

View 1 Replies View Related

Android :: Transparent Text Field

Apr 25, 2010

Is there any way to create a transparent text field?

View 4 Replies View Related

Android :: Using Text Field With AdapterView

Jun 2, 2010

Is it possible to use AdapterView with text fields in android?

My query returns a set of values and for each I want to place that within a textfield, so that the user may edit the value.

Also, I want to click a button to create a new empty field, so that I may insert a new entry.

If you know of good example, then please let me know!

I would prefer to use XML to define ui and I found this informations:

"In this case we create a new id called text1. The + after the @ in the id string indicates that the id should be automatically created as a resource if it does not already exist, so we are defining text1 on the fly and then using it." Source http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html

Will this + allow me to autocreate as many fields as needed? Is there a way I can generically specify the layout in XML and then create fields adhoc based on db response?

View 1 Replies View Related

Android :: Virtual Keyboard - Text Field

Apr 5, 2010

I am having problem in Virtual Keyboard. I am having text field. if user click the text field then virtual keyboard need to appear. how to do this.

View 5 Replies View Related

Android :: Composition Field For Text Messages?

Nov 22, 2010

Has anyone else struggled with the size of the composition field for text messages?Sometimes I get long winded and then I have a hard time proof reading all of my words because the bubble is so small.I try to scroll up and down but it doesn't always work.

View 1 Replies View Related

Android :: Transforming Password Text Field

Jul 29, 2009

I can not get an EditText view to transform a password.

Here's the creation of my view:

CODE:.......

What I see on the screen is what I type. The text is not transformed.

View 5 Replies View Related

Android :: Activity On Soft Keyboard When No Text Field Present?

Jul 31, 2010

I want to open soft keyboard while starting an activity. The activity contains nothing as its element. I just need to open soft keyboard on the launch. I've tried with

<activity android:windowSoftInputMode="stateAlwaysVisible|stateVisible|adjustResize" but it didn't work.

Also tried with

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

but it didn't work as well i'm using emulator to run the code

View 1 Replies View Related

Android :: Default Keyboard Type For Html Text Input Field

Feb 22, 2010

Is there a way to set the default keyboard type for a html text input field for a webkit view on Android? Can this be done via CSS?

View 2 Replies View Related

Android :: Convert EditText Component From A Text Field To Numeric In Droid?

Oct 1, 2009

If I have an EditText component on my screen that I have specified inputType="decimal" for (i.e. a numeric/decimal field), what is the best way to convert it to an decimal value in the application code?

Google recommends avoiding floats, and avoiding creating objects unnecessarily (and I assume any auto-unboxing code is bad too), so I take these as my constraints. I realize a small application probably doesn't need to worry too much, but I haven't been able to find a 'best-practice' solution to this.

The most common solution appears to be this:

double value = Double.parseDouble(txtInput);

View 2 Replies View Related

Android :: EditText Bug - Set Field To Disabled It Greys Out And Cannot Enter Text With Hardware Keyboard

Aug 19, 2009

I have a simple EditText field in one of my Activities. If I set the field to disabled, it greys out and I cannot enter text with the hardware keyboard, however when I touch the field the virtual keyboard appears and that still lets me enter text. Is this a bug? Any workarounds for making sure this can't happen?

View 5 Replies View Related

HTC Incredible :: Touch Text Field On Browser

Aug 11, 2010

Say you are fully zoomed out on some internet page and you see a text field....you touch the text box to type in it. Instead of allowing you to type, it zooms in on the text box. Why? And sometimes, actually most of the time, it zooms in to the wrong area and I have to scroll around to find the text box I was going to type in. So, can I turn off that particular zoom feature? Or can the zoom feature be made accurate....because most of the time it is not accurate at all and the zoom completely misses the text box.

View 1 Replies View Related

General :: Limited Text Entry Field?

Dec 20, 2011

I have noticed that when using my phone to reply to a long string of text on forums (or at least some of them) I seem to hit a roadblock at some point. By that I mean, if I wanted to reply to a message like I am typing this right now, if I want to scroll down to the bottom I am unable to if the length of the text reaches a certain point. Or in another situation, I could be typing my reply, but once I write enough to reach that limit I am unable to type any further. This only applies when wanting to reply at the bottom of the string of text. There are ways to work around the issue, but in certain cases they aren't always preferred.

View 4 Replies View Related

Android :: How To Use Three Unicode Values In Android In Text Editing Area?

Oct 12, 2010

I am trying to display two Hindi characters in the text editing area. These characters are a combination of three unicode characters. For example: In order to display number 9, I use HTE following in the XML file:
<Key android:codes="57" android:keyLabel="9"/>

One character is a combination of three unicodes --> 0915 094D 0937 How should the XML file be modified in order to display the above two hindi characters ? How can I use three unicode values in android: codes in the text editing area?

View 3 Replies View Related

Filter ListView When Typing Text Into EditText Field?

Sep 26, 2013

I am trying to filter a ListView when typing text into an EditText field. With the onTextChanged() method I have now, the app crashes when trying to type in the EditText field.

[HIGH]import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;[code]......

View 2 Replies View Related

General :: Paste Copied Text Into Blank Field On ICS?

Dec 11, 2011

can't trigger the paste text actie option.

Is there a link or tutorial somewhere on how copy / paste / select text is supposed to work?

View 14 Replies View Related

Sony Ericsson Xperia X10 :: Voice Input In Any Text Field

May 26, 2010

I have been looking for something similar to the feature which is available on the Nexus one, which is the ability to enter text via speach on any text input.

I know its available for the google search on the X10, but does anybody know if its available for every text box?

View 3 Replies View Related

General :: Clearing Suggestive Text In Email To Field On Samsung Galaxy S3?

Nov 11, 2013

I have a Samsung Galaxy S3 (4G). In the email application (standard) it seems to store all of the email addresses from emails I've received, even SPAM emails.

Now when I send an email and enter the "to" field, it suggests these email addresses. How do I clear out all of these stored suggestive email addresses from my phone? None of them are in my contacts lists.

Im using just normal pop email and the standard email app. I've tried cleaners, clearing cache, deleting email accounts - everything.

View 4 Replies View Related

Android :: Resource In Conflict

Sep 4, 2010

My application has resource conflict problem. Did some investigation, seems like all the resources within the apk file are cached after they are loaded on demand. The cache is stored in Resources.java mDrawableCache. The key to retrieve the drawable from this cache is combining the data and assertCookie fields of TypedValue class. In my application, there are 2 resources, ex. a color background and image drawable, evaluated to the SAME key value.. So just wondering, how can it happen?BTW, I am using eclair SDK.

View 2 Replies View Related

Android :: AllowTaskReparenting And FLAG_ACTIVITY_CLEAR_TOP Conflict

Dec 14, 2009

I am using Android 2.0 and have the following situation:

CODE:..........

This activity belongs to a task that has a service running and is usually not killed, so even when I am in the home screen I see the task running on DDMS (I will call it Task A).

It is possible to start Activity A from another application (running on Task B). When it is launched, I assume Activity A is "reparented" to the Task A. I assume that, because the debugger stops on the breakpoint I have set on onCreate and I am debugging Task A only. Please, advise if this is not correct.

So at this point, as far as I can tell, Task A has only Activity A. When in this situation, the service running on Task A receives some event and puts a notification on the Notification bar. This notification, if clicked, will send an Intent that also starts Activity A (this Intent has flags FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TOP).

Now to the problem, what I expected is that, because of the CLEAR_TOP flag, Activity A would be destroyed and recreated, as it has standard launch mode. But what I observe is that another Activity A launches on top of the previous one. When I click BACK on the new instance of Activity A, the old instance is redisplayed, what for my use case is wrong. Note that this only happens when launching Activity A from another application. If I launch it from my application and click on the event on the notification bar, it is destroyed and relaunched.

View 2 Replies View Related

Android :: SMS BroadcastReceiver Conflict With GPS LOCATION_SERVICE

Mar 1, 2009

SMS BroadcastReceiver conflict with GPS LOCATION_SERVICE.

Code is here:

CODE:.................

View 2 Replies View Related

General :: How To Edit Default Values Of Memory Min-free Values Of Rom Reside

Apr 9, 2014

I want to ask where does the defaults values of memory min-free values of a Rom reside? I mean what file I would have to edit to edit those values?

View 1 Replies View Related

Android :: Setting A New Typeface To All Text Views

Jan 12, 2010

I've created a custom Typeface by adding a TTY file to the assets folder, and I use the set Typeface method to apply this font to each of the text views, and everything works great. The only problem I have, is that I write a lot of code lines in order to apply this font to all text views. Is there a way to make this font the default font in my project, or to apply it to all text views at once?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved