我在ViewPager
中有几张图片可供用户滑动,我需要在TextView
中显示图片的名称。我只是靠java
,然后想像代码将是这样的。
private void displayName (String name) {
/*
This is the code to get the name of the image that appears in the ViewPager
*/
ViewPager swipeImages = (ViewPager) findViewById(R.id.myImageSwipe);
String backgroundImageName = String.valueOf(swipeImages.getTag());
/*
This is the textView where I need the name of the image file to display
*/
TextView imageNameTextView = (TextView) findViewById(R.id.nameImage);
imageNameTextView.setText(name);
displayName(backgroundImageName);
}
答案 0 :(得分:0)
您是否将图像文件名设置为图像视图?如果是这样,您可以为文本视图设置相同的名称。
imageNameTextView.setText(backgroundImageName);