开发者

accessing the children views of a View in Android

I am quite new to Java, let alone Android. I am stuck with a problem that I encountered while instrumenting (using the instrumentation framework of android) the code of a Android project. I have a ListView and using the getTouchables() API I have store the view in a ArrayList. When in debug session, I sa开发者_StackOverflow社区w that each view has children (mChildren) when expanded I could see that there is a "ImageView" and "TextView" present. when the "TextView" is expanded, I could access the mText variable which contains the text value I am looking for. In brief, the value I am looking for, when looking at the "variables" window of the debug perspective of Eclipse, is present at 'myview->mChildren->[1] (TextView)->mText->value'

Here "myview" is the name of the object of View class.

how do I access/ read the content of the "value" variable?

Please let me know if you need any info in this regard?

Thank you -BA


You could access via the findViewByID method of the mView object;

For example

TextEdit mText = (TextView)myView.findViewById(R.id.mText);
mText.setText("Hello!");

Hope that's what you're after or helps.

Damon

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜