2012-05-10 7 views
0

1のテキストを取得します。私は以下のようにリストビューを持っている:Robotiumは、リストビュー

sort 
game 
play 
home 

どのように我々は、上記のリスト一つ一つまたはrobotium内のすべてのいずれかのすべてのテキストを取得することができます。

2:SDカード(エミュレータ)でファイルを作成する方法はありますか?

方法を提案してください。

答えて

0

親がリストである場合、solo.getCurrentTextViews(View parent)を使用できます。 2番目の質問は、最初の質問については、この1

Context ctx = getInstrumentation().getContext(); 
AssetManager assetManager = ctx.getAssets(); 
File a = ctx.getFilesDir(); 
a.createNewFile(); 
0

は、私の解決策は次のとおりです。

RelativeLayout rowItem; 
      for (int i = 0; i < listView.getChildCount(); i++) { 
       rowItem = (RelativeLayout) listView.getChildAt(i); 
       TextView tv = (TextView) rowItem 
         .findViewById(R.id.my_tv); 
         String text = tv.getText(); 

      } 

2番目の質問: 間違いなく、あなたがここ

1

を試してみてください答える

0

が私の解決策であることができますListViewアイテムから一意の名前を取得する方法:

//check if ListView contains elements by getting ListView size 
int index = 0; 
int elemCount = 0; 
ListView listView = (ListView) solo.getCurrentListViews().get(index); 
elemCount = listView.getAdapter() != null ? listView.getAdapter().getCount() : 0; 

//Creating a Map of existing elements 
Map<String, Integer> namesMap = new HashMap<String, Integer>(); 

//Going through the list of elements and mapping it's names 
for (int i = 0; i < elemCount ; i++) { 

    String name = ((StructureElement) listView.getAdapter().getItem(i)).getName(); 
    namesMap.put(name , i); 

} 

Log.i("Names and indexes are : " + namesMap); 

ListItemの名前でインデックスを取得する場合はnamesMapを返し、そのインデックスでListItemの名前を取得する場合は「逆の場合」を返す追加のメソッドを作成するだけです。

+0

はgetCurrentListViews(何が)それを再利用してお気軽に)ソロで存在していないようです – behelit

関連する問題