저는 android.I에 새롭습니다. 선택한 이미지와 함께 변경되는 버튼이있는 textview를 추가하는 방법을 모르겠습니다. 누구든지 적절한 코드를 통해 나를 도울 수 있습니다. 어떻게해야합니까? 도움을 주시면 감사하겠습니다.갤러리의 버튼이있는 텍스트 뷰
-3
A
답변
0
응답을 지우려면 개체를 보관할 컬렉션 또는 arraylist를 설정 한 다음 클릭 한 내용을 기준으로 참조하십시오.
이미지가 액티비티의 유일한 객체 인 경우 단일 이미지에서이를 수행하는 방법은 다음과 같습니다.
XML :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/image"
android:src="@drawable/YOUR_IMAGE_RESOURCE"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text for the picture"
android:visibility="invisible"
android:id="@+id/text"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:id="@+id/button"
android:visibility="invisible"
/>
</LinearLayout>
자바
ImageView photoImage = (ImageView)findViewById(R.id.image);
TextView text = (TextView)findViewById(R.id.text);
Button button = (Button)findViewById(R.id.button);
photoImage.setOnClickListener(new OnClickListener{
void onClick(View v){
text.setVisibility(View.VISIBLE);
button.setVisibility(View.VISIBLE);
}
});
// Set the OnClickListener for "button" here, to start a new intent or whatever
여러 버튼을 사용하는 경우, 설치 ArrayList에 또는 수집 제가 위에서 언급있다.
그런 다음 당신이에 따라 원하는대로 할 수
List<TextView> tvs = new ArrayList<TextView>();
// Setup the views
for (int i = 0; i < numberOfTextViews; i++){
TextView thisTextView = new TextView(context);
// Setup whatever layout info you want here
tvs.add(thisTextView);
}
// Use a view inflater here to add each of the textviews however you want (table layout, linearlayout, etc.)
[편집]
배열 목록에 뭔가를 넣어 귀하의 코드는 다음과 같습니다 ... 그냥 ... tvs.get(NUMBER)
을 사용하여 원하는 내용을 찾으십시오. 버튼이나 다른 것을 사용하여 동일한 작업을 수행 할 수 있으며 동일한 NUMBER를 사용하여 문자열, 텍스트 뷰 및 버튼을 동시에 참조 할 수 있습니다. 예 : 버튼 번호 1을 클릭하십시오. tvs.get(1)
, buttons.get(1)
, stringResources.get(1)
더 적합한가요?
+0
내 코드를 업데이트했습니다. – RyanInBinary
관련 문제
- 1. 갤러리의 텍스트 뷰 업데이트
- 2. Android ExpandableList 뷰 버튼이있는 부모
- 3. ExtJs의 버튼이있는 텍스트 필드 확장
- 4. 이미지 갤러리의 텍스트 숨기기 - SEO 의미
- 5. 텍스트 뷰
- 6. 텍스트 뷰
- 7. 텍스트 뷰
- 8. 텍스트 뷰
- 9. 설정 이미지 뷰 텍스트 뷰
- 10. 텍스트 뷰 랩 텍스트 서체
- 11. 완료 및 완료 버튼이있는 iPhone 텍스트 입력
- 12. wpf는 openfiledialog 버튼이있는 텍스트 상자를 만듭니다.
- 13. 내가 텍스트 상자와 버튼이있는 JOptionPane에 원하는
- 14. 그림이없는 사용자 지정 갤러리의 성능
- 15. 버튼이있는 Texbox
- 16. 갤러리의 그림으로 이미지 변경하기
- 17. android - 다른 뷰 중앙에 텍스트 뷰 정렬
- 18. ImageMenuItem 및 텍스트 뷰
- 19. 안드로이드 : 텍스트 뷰
- 20. 텍스트 뷰 배경 자원
- 21. 동적 텍스트 뷰 만들기
- 22. 여러 텍스트 뷰
- 23. 텍스트 뷰 색상을 클릭
- 24. positiong 화면의 텍스트 뷰
- 25. 텍스트 뷰 라인 - 조언
- 26. NullPointerException이 : 텍스트 뷰 값
- 27. 텍스트 뷰 천막
- 28. 안드로이드 텍스트 뷰 위치
- 29. HTML은 텍스트 뷰
- 30. 텍스트 뷰 투명화
버튼이있는 textview를 추가 하시겠습니까? 그게 무슨 뜻 이죠? 문제를 해결할 수 있도록 좀 더 분명하게 찾으십시오. – RyanInBinary