?
Solved

In a loop through all Childs on my LinearLayout, how can i separte the buttons ? what am i missing in the following code

Posted on 2014-09-10
2
Medium Priority
?
159 Views
Last Modified: 2014-10-03
Hello,

I'm working on some tests and i would like to be sure that in my NiceActivity there is four buttons that are displayed.
In this activity i also have textEdit view.

I'd like to separete - count - my buttons in a test but when i try to check if a view is a button I can not pass my test.


Here 's my method :
commented are two test that didnot work. In my debug i can see that the v.getClass().getSimpleName() is "Button" but if I compare it to "Button" i receive false.....help ;)




private ArrayList<Button> GetOnlyButtonsOutOfLayout(LinearLayout aLinlayout) {
        ArrayList<Button> response = new ArrayList<Button>();
        int childcount = aLinlayout.getChildCount();
        Log.i(_className, "fils de layout: " + childcount);

        for (int i=0; i < childcount; i++){
            View v = aLinlayout.getChildAt(i);
            //if(v.getClass().getSimpleName().toString() == "Button" ){
            //if(v.getClass().getSimpleName() == Button.class.getSimpleName() ){
            Log.i(_className, v.getClass().getSimpleName());
            if(v.getClass().getSimpleName() == "Button"){
                response.add((Button) v);
            }
        }
        return response;
    }


my response is always empty.

how can i do this.

thank you in advance for your help.

toshiro
0
Comment
Question by:toshi_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Accepted Solution

by:
toshi_ earned 0 total points
ID: 40359331
i've added a new layout in order to have all  buttons separted.
since then i could easily pass my test.

toshi
0
 

Author Closing Comment

by:toshi_
ID: 40359334
could not cast view elements to know what they were , if they were button or textview....
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
You should read OS supplied guidelines before developing. I can't stress that enough. The guidelines will help you understand the reasons mobile app developers do what they do.  Apple is very particular when they review appstore submissions.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question