Android :: ArrayList In Adapter Not Working / Using History Share Method
Nov 21, 2010
I retrieve Json data (the JSONArray) and I wanted to make a List of all the names in the JSONArray, something like this.
List list = new ArrayList<String>();
for(int i=0;i < data.length();
i++){list.add(data.getJSONObject(i).getString("names").toString());}
And I wanted to take this list in an `ListView' so I did this:
ArrayList<String> test = history_share.list;
names_list = (String[]) test.toArray();
ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, names_list);
setListAdapter(adapter);
History_share is one of the method I created to take json data from an api. Eclipse doesn't see any error, and me neither.
View 1 Replies
Jun 15, 2010
I have two applications which i want them to share the same arraylist.
How could i achive something like that? is there anything in Android for sharing such a prefrenceses?
View 2 Replies
View Related
Jun 30, 2010
I'm assuming that your input XML is very simple and uses no element attributes, namespaces, or recursively nested elements. I recommend you use the following pattern, which I've used countless times:
Use a StringBuffer or StringBuilder to collect character data. Initialize it in startElement. In the characters method, do only the following: sb.append(ch, start, length). Please note that SAX parsers are not required to return the full contents of a text node in a single call to characters(). For efficiency, the parser may use an input buffer which may be smaller than a particular text node. A lot of people seem to miss this. Do the major processing in the endElement() method.
Do you use a debugger to step through your code?
View 10 Replies
View Related
Jun 18, 2010
I have seen examples implementing a custom Filter. The Android developer docs talk about implementing a Filterable interface. Does anyone have any advice and/or sample code on the best way to implement filtering in a ListView ?
View 2 Replies
View Related
Dec 7, 2009
I have implemented a custom adapter the extends from the BaseAdapter and implements the getView method. It works fine except for one thing, not once do I get the convert View (a parameter to the getView method) that is not null (that can be reused).
View 2 Replies
View Related
May 12, 2010
I am trying to use annotation - method.getAnnotation( ) or method.isAnnotationPresent( ) and it is not working. I am using eclipse emulator for 2.1 OS version with JDK 1.6. Following is information about what I did..................
View 4 Replies
View Related
Mar 1, 2010
I have an ArrayAdapter (myAdapter) attached to an AutoCompleteTextView (textView)component. Once the user presses a character I would like to populate AutoCompleteTextView's drop down list with items containing this character. I retrieve the items using AsyncTask (which uses a web service).
I call myAdapter.add(item) but the drop down list is empty.I added a call myAdapter.getCount() after each addition and it shows zero every time.
Calling notifyDataSetChanged() didn't help.I even tried to add simple String objects instead of my custom objects, to no avail.What am I doing wrong?
Edit: I changed the code as miette suggested below but still to no avail.
Generally, what I do is after text is changed in my auto complete text view, I call a new AsyncTask and pass it the entered text and a Handler (see afterTextChanged()). The task retrieves objects relevant to the text and once done the Handler's handleMessage() is called. In handleMessage() I attempt to populate the adapter's objects. But still the adapter's drop down list ends up empty.
Here is my code:
public class AddStockView extends Activity implements OnClickListener, OnItemClickListener, TextWatcher {
ArrayAdapter<Stock> adapter;
AutoCompleteTextView textView;
Vector<Stock> stocks;
public AddStockView() {
// TODO Auto-generated constructor stub
stocks = new Vector<Stock>();}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.add_stock_view);
findViewById(R.id.abort_button).setOnClickListener(this);
adapter = new ArrayAdapter<Stock>(this,
android.R.layout.simple_dropdown_item_1line, stocks);
//adapter.setNotifyOnChange(true);
textView = (AutoCompleteTextView)
findViewById(R.id.search_edit_text);
textView.setAdapter(adapter);
textView.setOnItemClickListener(this);
textView.addTextChangedListener(this);} Code...
View 3 Replies
View Related
Oct 3, 2009
I just got an audio adapter for my magic so that I can use my headphone but it does not seem to work, the sound still comes from the inbuild speaker! Should I set summit up or am i missing something?
View 2 Replies
View Related
Jul 24, 2009
This is my first post to the forums so I hope this is in the right place.
I recently bought a Vodafone HTC Magic in Australia (and am loving it and the Android OS ).
I also bought myself two adapters for it, one was a cheap one which plugs into the usb port and just becomes a 3.5mm plug (which fell to pieces rather quickly) and another which was more expensive and a 4 in one adapter. It allows you to plug in headphones and charge at the same time.
It can be found here:
4in1 3.5mm USB Adapter for T-mobile G1 G2/HTC Magic - eBay Other Data Cables, Data Cables, Mobile Accessories, Phones. (end time 25-Jul-09 19:12:35 AEST)
My problem is that the more expensive adapter doesn't work. The cheap one worked fine, but when I plug this one in, the sound won't come out of the headphones.
I managed to get the sound to come out the adapter as long as I plugged the headset supplied with the phone into the adapter. The sound would still come out when I removed the headset.
I think it's the phone just needs to be set in a mode that plays the sound through the adapter, but I'm not sure.
View 2 Replies
View Related
Nov 19, 2010
I am using the showDialog and dismissDialog methods to show progress dialogs in my app. Moved from creating the dialog and calling show() on it to using this in order to save state when changing orientation.But when I change the orientation from portrait->landscape->portrait, the dismissDialog no longer dismisses the dialog. The dialog stay there all the time and I need to press the back button for it to disappear.
View 2 Replies
View Related
Jun 12, 2010
As it has already been noted in EVO threads, SystemPanel App / Task Manager history /installer and a few other features no longer work. That is because it has finally broken into a lite ver and paid ver.
The lite (free) might be fine for most. The paid is $2.99, well worth it IMO.
View 7 Replies
View Related
Oct 19, 2010
This works great for files.I marked the location needing refactoring to get it to work with a bitmap. I can't seem to find a compatible ContentBody for .addPart.The problem I am trying to solve is that I already have the image in an ImageView within an Activity, so rather than read it again from the SD cara, I want to pass it to this method directly.I will probably scale it while I am at it.
View 1 Replies
View Related
Sep 16, 2010
I have an Activity which contains a ListView defined in XML (its not subclassing the List Activity class).I want to display a message when the ListView is empty, so I tried doing so with the setEmptyView method: Code...
View 2 Replies
View Related
Jan 1, 2014
I'm currently having some issues with my S4 mini, as stated in the title, the phone does not save messages or calls. I can still send and call, but nothing is ever recorded.
At the same time this started to occur my play store stopped working, just getting the "no connection, Reconnect"
I am using the stock app from samsung for calls and messages. Factory reset is something i would like to avoid.
View 4 Replies
View Related
Jun 24, 2010
For the rest of us peasants who still can't get into that f*@#&$g shell?
View 23 Replies
View Related
Jan 5, 2010
I am just wondering if anyone would like to share pics of how you have you 7 screens setup.
View 49 Replies
View Related
May 21, 2009
I am using the showDialog and dismissDialog methods to show progress dialogs in my app. Moved from creating the dialog and calling show() on it to using this in order to save state when changing orientation. But when I change the orientation from portrait->landscape->portrait, the dismissDialog no longer dismisses the dialog. The dialog stay there all the time and I need to press the back button for it to disappear.
To overcome this issue, I tried adding a removeDialog in onDestroy so that the dialog is not created/displayed twice and before orientation change, the dialog is removed. Tried adding log statements and see what happens:
05-21 12:35:14.064: DEBUG/MyClass(193): callingShowDialog
05-21 12:35:14.064: DEBUG/MyClass(193): onCreareDialog
05-21 12:35:15.385: DEBUG/MyClass(193): onSaveInstanceState
05-21 12:35:15.415: DEBUG/MyClass(193): onDestroy
05-21 12:35:15.585: DEBUG/MyClass(193): callingShowDialog
05-21 12:35:15.585: DEBUG/MyClass(193): onCreareDialog
05-21 12:35:15.715: DEBUG/MyClass(193): onCreareDialog
05-21 12:35:17.214: DEBUG/MyClass(193): onSaveInstanceState
05-21 12:35:17.214: DEBUG/MyClass(193): onDestroy
05-21 12:35:17.275: ERROR/WindowManager(193): android.view.WindowLeaked: Activity com.android.MyClass has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43362088 that was originally added here
05-21 12:35:17.395: DEBUG/MyClass(193): callingShowDialog
05-21 12:35:17.395: DEBUG/MyClass(193): onCreareDialog
05-21 12:35:17.475: DEBUG/MyClass(193): onCreareDialog
If we see here, initially when the activity is displayed, the onCreateDialog is called once and on changing the orientation, onSaveInstanceState and onDestroy are called. But after that, onCreateDialog is called twice (once by a call to showDialog which I make, but why the 2nd time?) and this happens every time I change the orientation hence forth.
View 5 Replies
View Related
Aug 26, 2010
I am writing automated test cases using Instrumentation. "waitforMonitorWithTimeout" always timesout. If I use waitForMonitor everything is fine. The two lines of code are below. (I comment out one of them when building my test project). Are there known issues with "waitforMonitorWithTimeout"? I have to use the timeout to determine if an event occured (and thus transition to a new activity) or not.
View 2 Replies
View Related
Sep 7, 2010
I'm trying to override the onBackPressed() method of the ActivityGroup class:
public class MyClass extends ActivityGroup {
@Override
public void onBackPressed() {
// do something
return;
}
but I'm getting the error The method onBackPressed() of type MyClass must override a superclass method. I'm relatively new to Java, I've seen here that people do it and it works for them Why I'm getting this error? I'm writing an app for android 1.5, could the problem be here?
View 1 Replies
View Related
Nov 22, 2010
In Eclipse, when I mouse hover over a built-in method, it displays a method definition including stuff like what the method does, input objects, return objects etc. If I have a yellow line (warning) under the method I'm trying to use, I can't get the mouse-over to show the definition. If I try hitting F3, I get a "The Jar of this class file belongs to container "Android 1.6" How do I show the definition of the method I am using when there is a warning?
View 1 Replies
View Related
Sep 9, 2009
I'm new to android developing and I've done a function which return an arraylist type ArrayList<ArrayList>. I would like to display this arraylist for see if my function work.
View 11 Replies
View Related
Oct 9, 2010
I'm writing my own custom view, a keyboard, which I think the ArrayList in the keyboard view is causing the application to quit in the emulator.
public static ArrayList<HexButton> hexButtons = new ArrayList<HexButton>();
The application ran fine when I did
setContentView(myKeyboardView);
But I want to nest my keyboard with a TextView so I'd like to be able to do
setContentView(R.layout.main);
View 2 Replies
View Related
Nov 12, 2010
Is there a way to pass an Array List of objects between activities? The myObject implements Parcelable and I'm able to successfully pass the objects around individually, but that means I need to have an exact amount of "myObjects" coded. I want this to dynamically grow/shrink by what the user does with the app. I have seen some posts on the web about doing:
Activity A
ArrayList<myObject> myObjArray = new ArrayList<myObject>();
Then when passing this into the intent I would use:
intent.putParcelableArrayListExtra("myObjArray", myObjArray);
Activity B
ArrayList<myObject> myObjArray = new ArrayList<myObject>();
Bundle extras = getIntent().getExtras(); myObjArray = extras.getParcelableArray("myObjArray");
However, the myObjArray always gets filled with "null". How can I achieve this?
View 3 Replies
View Related
Apr 7, 2009
I have an ArrayList<MyList> aList in an activity. I would like to send this data to another activty. Such that,
ArrayList<MyList> aList;
Intent intent = new Intent(); intent.setClass(mainactivity.this, newActivity.class); intent.putExtra("MyList", aList ); startActivity(intent);
On the receiving activity,
Intent i = getIntent(); newList = (ArrayList<MyList>) i.getSerializableExtra("MyList");
But this gets me no where. ERROR! My intention is to share this List between activities.
View 4 Replies
View Related
Nov 16, 2009
Can any one tell me how to store and retrieve arraylist in/from sqlite.
ArrayList<Double> results = new ArrayList<Double>();
View 4 Replies
View Related
May 30, 2010
I was trying to serialize an ArrayList which contains custom objects. I'm serializing it in a Servlet (server side), and deserialize at the client side. (using ObjectOutputStream and ObjectInputStream)
It worked fine, when I work with ArrayList<String>.
But when I tried it with ArrayList<MyObject> I couldn't get any results in the client side, this is the exception:
java.lang.ClassNotFoundException: web.MyObject
Of course I have done this:
public class MyObject implements Serializable { ... }
MyObject contains only String fields.
View 1 Replies
View Related
Jun 8, 2010
I want the contains() method from ArrayList to be case insensitive. Is there any way?
View 1 Replies
View Related
Aug 19, 2010
I am trying to add an object to an arraylist but when I view the results of the array list, it keeps adding the same object over and over to the arraylist. I was wondering what the correct way to implement this would be.
CODE:..............
I have double checked my JSONArray data and made sure they are not duplicates. It seems to keep adding the first object over and over.
View 2 Replies
View Related
Aug 26, 2010
I want to save an ArrayList so that it is persistent. The contents can change. What is the best way of approaching this in android?
View 2 Replies
View Related
Oct 27, 2010
I want to pass an Arraylist from one activity to another. I use putStringArrayListExtra(), but there shows an error : "The method putStringArrayListExtra(String,ArrayList is undefined for the type bundle." Is there any other method available for passing ArrayList?
CODE:..................
View 3 Replies
View Related