여기에 꽤 쉬운 질문이 있습니다. 그러나 나는 아직 자바 수퍼 유저가 아닙니다.Viewflipper에서 동적으로 텍스트 뷰를 변경하십시오.
저는 여러 개의 이미지를 제공하기 위해 ViewFlipper를 사용하고 각 이미지에 특정한 텍스트를 포함하는 슬라이딩 서랍을 사용하고 있습니다. 슬라이딩 서랍의 텍스트를 현재 표시되는 하위 뷰에 따라 특정 문자열로 변경하고 싶습니다.
여기<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Prev" />
<Button
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next" />
</LinearLayout>
<ViewFlipper
android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image1"></ImageView>
<ImageView android:id="@+id/imageView2" android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/image2"></ImageView>
</ViewFlipper>
</LinearLayout>
가 자바입니다 : 여기 은 XML입니다
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
flipper = (ViewFlipper)findViewById(R.id.flipper);
next = (Button) findViewById(R.id.next);
previous = (Button) findViewById(R.id.previous);
imageview1 = (ImageView)findViewById(R.id.imageView1);
imageview2 = (ImageView)findViewById(R.id.imageView2);
next.setOnClickListener(this);
previous.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == next) {
flipper.setInAnimation(inFromRightAnimation());
flipper.setOutAnimation(outToLeftAnimation());
flipper.showNext();
}
if (v == previous) {
flipper.setInAnimation(inFromLeftAnimation());
flipper.setOutAnimation(outToRightAnimation());
flipper.showPrevious();
}
}
내가 대답은 정말 분명 확실 해요,하지만 난 당신의 도움이 .... 감사를해야 할 이유입니다!
slidingdrawer 코드는 어디에 있습니까? – Jack