关于重签名:
方式一:用resign.jar,下载地址: http://www.troido.de/re-sign.jar 直接把apk文件拖入即可
相对坐标:
View topView = solo.getView("topId"); View bottomView = solo.getView("bottomId"); View targetView = null; Listviews = solo.getViews(); int[] xy_top = new int[2]; int[] xy_bottom = new int[2]; topView.getLocationOnScreen(xy_top); bottomView.getLocationOnScreen(xy_bottom); for(View view : views){ int[] xy = new int[2]; view.getLocationOnScreen(xy); if(xy[1] < xy_top[1] && xy[1] >xy_bottom[1]){ targetView =view; break; } }

public void testSameView(){ Log.e(solo.getConfig().commandLoggingTag, solo.getCurrentActivity().getLocalClassName()); ListView listView = solo.getView(ListView.class,0); int total = listView.getCount(); Log.e(solo.getConfig().commandLoggingTag, "listview size:" + total); String tmp_text = null; for(int i = 0;i<total;i++){ solo.scrollListToLine(listView, i); List<View> views = solo.getCurrentViews(); int targetID = solo.getCurrentActivity().getResources().getIdentifier("crime_list_item_titleTextView", "id", "com.bignerdranch.android.criminalintent"); List<View> result = new ArrayList<View>(); for(int tmp=0;tmp<views.size();tmp++){ if(targetID == views.get(tmp).getId() && views.get(tmp).isShown() && views.get(tmp).getVisibility() == 0 && views.get(tmp).isEnabled()){ result.add(views.get(tmp)); } } TextView tagert_tv = null; int size = result.size(); Log.e(solo.getConfig().commandLoggingTag, "all title size :" + size); if(total - i <= size){ Log.e(solo.getConfig().commandLoggingTag, "i=" + i); tagert_tv = (TextView)result.get(i + size - total); //为了兼容屏幕不是显示完整的item if(tmp_text != null && tmp_text.equals(tagert_tv.getText().toString())){ tagert_tv = (TextView)result.get(i + size - total + 1); } } else{ tagert_tv = (TextView)solo.getView("crime_list_item_titleTextView"); } Log.e(solo.getConfig().commandLoggingTag, "crime title is :" + tagert_tv.getText().toString()); tmp_text = tagert_tv.getText().toString(); solo.clickOnView(tagert_tv); solo.goBack(); solo.waitForView(ListView.class); listView = solo.getView(ListView.class,0); } }
有错误或建议,请留言指出,我会尽快回复,谢谢。