Setting clickable on individual ListView's ChildViews

by chiizuf...@googlemail.com » Wed, 04 Mar 2009 23:50:16 GMT


Sponsored Links
 Hi,

I'm in a situation where I have a ListView in which I want some of the
entries to be clickable and some not to be. Setting
listView.setClickable(false) disables clicks on everything even if
textView.setClickable(true) is set when the child view is being added
in my customised ArrayAdapter. Conversely, leaving clickableness of a
ListView at the default of true, textView.setClickable(false) doesn't
work.

I've tried:

textView.setClickable(false);
textView.setFocusable(false);
textView.setFocusableInTouchMode(false);
textView.setLinksClickable(false);
textView.setLongClickable(false);
parent.setClickable(false);
parent.setFocusable(false);
parent.setFocusableInTouchMode(false);
parent.setLongClickable(false);

but none of them have any effect.

The issue at
 http://code.google.com/p/android/issues/detail?id=625& ;can=1&q=clickable&colspec=ID%20Type%20Version%20Security%20Status%20Owner%20Summary
notes that clicks don't go to the child view in a ListView. This being
the case, is it even possible to disable clicks for an individual
element which isn't a header?

Thanks =].

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



Setting clickable on individual ListView's ChildViews

by chiizuf...@googlemail.com » Thu, 05 Mar 2009 18:40:33 GMT


 Thanks for your reply,

What do you mean by disable the items in my adapter?




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


Sponsored Links


Setting clickable on individual ListView's ChildViews

by chiizuf...@googlemail.com » Fri, 06 Mar 2009 18:13:48 GMT


 Aha, figured it out. By overriding isEnabled in my adapter I can check
whether a certain position should be clickable or not.

Thanks! :D

Open source is fun... :D

On Mar 5, 10:40am, "chiizuf...@googlemail.com"




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



Other Threads

1. i want to put up calendar in main screen

Hi i am new to android .

i want to put up calendar in emulator.

on selecting which displays dates and events in it.

please do help me

-- 

2. Can't dynamically update ListAdapter for ListView

Hello, friends!

I have a problem with adding new items to ListView.

I use custom adapter MyListAdapter. I do that way:

public class MyView extends ListActivity{

    private ArrayList<Order> m_orders = null;
    privateMyListAdapter m_adapter;
    private Runnable viewOrders;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        m_orders = new ArrayList<Order>();
        this.m_adapter = new OrderAdapter(this, R.layout.row,
m_orders);
        setListAdapter(this.m_adapter);

        viewOrders = new Runnable(){
            @Override
            public void run() {
                getOrders();
            }
        };
        Thread thread =  new Thread(null, viewOrders,
"MagentoBackground");
        thread.start();
        m_ProgressDialog = ProgressDialog.show(MyView.this,
              "Please wait...", "Retrieving data ...", true);
    }
    private Runnable returnRes = new Runnable() {

        @Override
        public void run() {
            if(m_orders != null && m_orders.size() > 0){
                m_adapter.notifyDataSetChanged();
                for(int i=0;i<m_orders.size();i++)
                m_adapter.add(m_orders.get(i));
            }
            m_adapter.notifyDataSetChanged();
        }
    };

    private void getOrders(){
          try{
            m_orders.addAll(/*some order collection*/)
            runOnUiThread(returnRes);
        }

    private class OrderAdapter extends ArrayAdapter<Order> {
        //code about how to get view
}
}

But when I add items to my adapter:
 for(int i=0;i<m_orders.size();i++)
                m_adapter.add(m_orders.get(i));
the application hangs because of m_orders increase there size,
everytime where new item adds to adapter.

Friends, do you have any ideas how to implement dynamically adding
items to custom ListAdapter? Do you see any errors in my code?

Thank you very much :)))

-- 

3. How Display list of all video files on android system?

4. Custom view disappears, when scrolling

5. "Platform Versions" page on android.com

6. Idiom / pattern for clean database (and other resource) management within a Service

7. Camera Questions: 1) Raw Bayer data, 2) NDK camera access