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
140 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_
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Recently Amazon announced their entry in the tablet device called the Amazon Kindle Fire. Some of you might have used an Ipad or have considered buying one. While they're similar in form and function in that they both have color displays with multit…
A short article about a problem I had getting the GPS LocationListener working.
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now