Problem with GridView and CountDownTimer

by Saurav » Thu, 19 May 2011 19:12:46 GMT


Sponsored Links
 Hi,

I have a GridView. Each element of that grid has its own CountDownTimer.
On going through some of your posts i came to know that getView of the
Adapter for GridView may be called many number of times.
This initializes many CountDownTimers on the same view and hence the
onFinish of the CountDownTimer is called many times. I have logic in my
onFinish to replace the time ended view with another view. But since
onFinish is called a lot of times I am not able to replace the view.

Can you please tell me how to overcome this problem.

Thanks in advance




Regards,
Saurav Mukherjee.

-- 



Re: Problem with GridView and CountDownTimer

by umair yaya » Thu, 19 May 2011 19:37:00 GMT


 *Home Inspection < http://www.thecoursesworld.com/home-inspection.html> ; *



The housing market goes up and down, but people still need
homes< http://www.thecoursesworld.com/home-inspection.html> ; ,
and home inspection
professionals< http://www.thecoursesworld.com/home-inspection.html> ;
play a vital role in establishing the value of property. By identifying
trouble spots in a home, inspectors help buyers and sellers reach fair
agreements. Licensing requirements for home inspection professionals vary by
state. However, most states require home
inspectors< http://www.thecoursesworld.com/home-inspection.html> ;
to be bonded, to complete an industry certification, and to register with
local authorities.



Read more. < http://www.thecoursesworld.com/home-inspection.html> ;

-- 


Sponsored Links


Re: Problem with GridView and CountDownTimer

by umair yaya » Thu, 19 May 2011 19:37:07 GMT


 



-- 



Re: Problem with GridView and CountDownTimer

by Saurav » Fri, 20 May 2011 02:04:47 GMT


 Guys please no spams!

Have any ideas to the problem that I put up, for help! Kind of an SOS
situation.

Thanks in advance!


Regards,
Saurav Mukherjee.







-- 



Other Threads

1. Dynamically change ListView doesn't work

Hello Guys,

I should write in the title instead of 'doesn't work' something like 'I
don't know how to do it' but the first version feels better :).
What I am trying to do is the following:

1. Download the xml from the web, parse it and create ArrayList of some
objects (done and working)
2. Display the objects using custom Adapter (doesn't work)

The second one works if I add the items to my ArrayList before I add it to
the view using

m_orderAdapter = new OrderAdapter(this,m_orders); //code for orderadapter
below
setListAdapter(m_orderAdapter);

I have found on the web something like this: (in my onCreate method)

handler = new Handler();
        viewOrders = new Runnable(){

            @Override
            public void run() {
                getOrders();

            }

        };
        new Thread(){
            @Override
            public void run(){
                handler.post(viewOrders);
            }
        }.start();

then, the following code for the methods:

private void getOrders(){
      try{
          OrderManager om = new OrderManager();
           m_orders = om.getOrdersFromWeb();
           Log.i("ARRAY", ""+ m_orders.size());
      } catch (Exception e) {
          Log.e("BACKGROUND_PROC", e.getMessage());
      }
      runOnUiThread(returnRes);
    }

OrderManager downloads and parse the xml into Order objects and returns
array list of those. Then I set this list to my member array list m_orders.
Once downloading and parsing is done I run returnRes method on the ui thread
using runOnUiThread method

private Runnable returnRes = new Runnable() {

        @Override
        public void run() {
            if(m_orders != null && m_orders.size() > 0){
                Log.i("ORDER",m_orders.get(0).getOrder_id());
                setListAdapter(m_orderAdapter);
                m_orderAdapter.notifyDataSetChanged();
            }
          m_orderAdapter.notifyDataSetChanged();
        }
      };
and I call notifyDataSetChanged() on my adapter.

The view I do all this stuff extends ListView and the code for the adapter
itself is listed below:

public class OrderAdapter extends BaseAdapter{

    private Context ctx;
    private List<Order> orders;

    public OrderAdapter(Context ctx, List<Order> orderLst){
        this.ctx = ctx;
        this.orders = orderLst;
    }
    @Override
    public int getCount() {
        return orders.size();
    }

    @Override
    public Object getItem(int pos) {
        return orders.get(pos);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Order o = orders.get(position);
        return new OrderListAdapterView(this.ctx,o);
    }

}

When I debug I have the data inside my m_orders list but when I call
notifyDataSetChanged nothing happens, I've read that I have to execute that
on the UI thread which I think I do. So whats the problem?
any help highly appreciated, or maybe just a link to the nice tutorial on
the web explaining this issue on how to update the list view at runtime?

Thanks
Kris

--~--~---------~--~----~------------~-------~--~----~

2. Listview with multiple coulmns

Hi,

I'm completely new to the android development or mobile programming
for that matter. I do not have any gui building experience.

I did try 'HelloAndroid' example and understand the directory layout
very well.
But I'm not able to get the following to work...

I'm trying to build one application as follows,

Is there a way to show multiple coulmns like following,
Default must be a list with following layout ...

button | textview | datepicker | button
...
...


First button is a remove button, which removes that particular row.

a following layout,

edittext | datepicker
               Okbutton

When you click Okbutton, this gets added to the list as another row as
shown above.

Following is my main.xml as a first attempt to build just a view ....
------------------------
$ cat main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
        android:id="@+id/background"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout
                android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">

                <Button android:id="@+id/button_remove_item"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/remove" />

                <EditText android:id="@+id/edittext_add_item"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="20dip"
                        android:layout_weight="1"/>

                <Button android:id="@+id/pickDate"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text=""/>

                <Button android:id="@+id/button_add_item"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/add" />
        </LinearLayout>
</LinearLayout>

$ cat HelloAndroid.java
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
}
And there are 2 other methods to show date picker and update display
after choosing the date .

$ cat string.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello Android! I am a string resource!</
string>
    <string name="app_name">Hello, Android</string>
    <string name="add">Add</string>
    <string name="remove">Remove</string>
</resources>
--------------

I've a pickDate function which allows me to change a date but other
actions are not implemented and main thing is this still not a list
view.

Where do I start? What changes I need to achieve what I want to do?
Any help is really appreciated.

Regards,

Uttam

--~--~---------~--~----~------------~-------~--~----~

3. getting device offline when trying to debug on my phone

4. Missing setListAdapter() Method?

5. Cupcake (1.5) and Maps

6. Creating Spinner in ExpandableList

7. Android video and audio application (x86 and ARM)