카테고리 검색시 표시된 제품 중 price
을 보여주는 앱의 TextView
을 확인하려고합니다.필터 ID를 기반으로 한 텍스트 뷰어
저는 자동화를 위해 Robotium을 사용하고 있습니다. 목록보기의 아이들을 통해
트래버스 :
ListView --> (0)FrameLayout --> (1)RelativeLayout --> (0)ImageView --> (1)RelativeLayout -->(0)ImageView -->(1)TextView //id - name -->(2)TextView //id - price -->(3)TextView //id - other --> (2)RelativeLayout --> (0)ImageView --> (1)RelativeLayout -->(0)ImageView -->(1)TextView //id - name -->(2)TextView //id - price -->(3)TextView //id - other --> (3)RelativeLayout --> (0)ImageView --> (1)RelativeLayout -->(0)ImageView -->(1)TextView //id - name -->(2)TextView //id - price -->(3)TextView //id - other --> (4)RelativeLayout --> (0)ImageView --> (1)RelativeLayout -->(0)ImageView -->(1)TextView //id - name -->(2)TextView //id - price -->(3)TextView //id - other --> (5)RelativeLayout --> (0)ImageView --> (1)RelativeLayout -->(0)ImageView -->(1)TextView //id - name -->(2)TextView //id - price -->(3)TextView //id - other
내가 가격을 얻는 두 가지 방법을 알아낼 수 :
내가 현재보기를 얻을 계층 구조 (
아래solo.getCurrentViews(ListView.class)
) 같은 것이있다 색인을 통해 가격에 도달하십시오. 코드int index = 1; ListView view = null; List<ListView> productList = solo.getCurrentViews(ListView.class); view = productList.get(0); for (int i = 1; i < view.getChildCount(); i++) { RelativeLayout relativeLayoutDetails = (RelativeLayout) view.getChildAt(index++); // get the first RelativeLayout RelativeLayout productDetails = (RelativeLayout) relativeLayoutDetails.getChildAt(2); //get the inner child RelativeLayout TextView productName = (TextView) productDetails.getChildAt(0); System.out.println("********" + productDetails.getChildCount()); TextView price = (TextView) productDetails.getChildAt(2); System.out.println(productName.getText().toString() + "---"+ price.getText().toString()); }
같이이 코드의 문제는 나에게 price
를 제공하지 않습니다 TextView price = (TextView) hotelDetails.getChildAt(2);
하지만 나에게 other
텍스트 뷰를 (왜 몰라) 제공합니다. 또한 현재보기에서만 작동합니다. 전체 목록을 아래로 스크롤하여 각 제품마다 세부 정보를 얻을 수는 없습니다.
두 번째는 현재 뷰에 대한 모든
TextView
의를 가져오고price
ID를 기반으로 그들을 필터링입니다. 아래처럼 :ListView l = (ListView) solo.getView (android.R.id.list); int viewShown = l.getChildCount();
int total = l.getCount(); int i; int index=1; if (hotelsShown != 0) { for (i = 0; i < total/viewShown; i++) { List<TextView> textViews = solo.getCurrentViews(TextView.class, l); //get all the text views //filter for price for(TextView priceView: textViews){ if(priceView.id equals "price-id") //get this TextView. } solo.scrollDown(); solo.sleep(500); }
나는 내가 ID
를 기반으로하는 뷰를 필터링 할 방법을 모르는되는이 방법에 직면하고 문제. 또한 스크롤하는 동안 현재보기에서 하나 또는 두 개의 제품을 건너 뛰고 수정할 수 없습니다.
누군가가 이와 관련하여 제안 할 수 있다면 좋을 것입니다.
왜 각 ListView에 OnItemClickListener를 설정하지 않으시겠습니까? – Houcine
어떻게 도움이 될까요? 내가 목록 항목을 클릭하면 새로운 계층 구조가 생깁니다. 죄송합니다 안드로이드 자동화에 새로운입니다. –
코드를 추가하여 어댑터를 인스턴스화하고 목록보기로 설정하십시오. – Houcine