如何从一个滚动视图特定iamge ...如何从滚动视图中检索特定图像?
在我的应用我创建了两个活动....活动1,活性2及其相应的XML1,XML2
ACTIVITY 1:
package com.scroll;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1=(Button)findViewById(R.id.button1);
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent in=new Intent(MainActivity.this,Act.class);
startActivity(in);
}
});
Button b2=(Button)findViewById(R.id.button2);
b2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent in=new Intent(MainActivity.this,Act.class);
startActivity(in);
}
});
Button b3=(Button)findViewById(R.id.button3);
b3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent in=new Intent(MainActivity.this,Act.class);
startActivity(in);
}
});
}
}
活动2: package com.scroll;
import android.os.Bundle;
import android.app.Activity;
public class Act extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
XML 1:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="56dp"
android:layout_y="75dp"
android:text="Button" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="56dp"
android:layout_y="75dp"
android:text="Button" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="56dp"
android:layout_y="75dp"
android:text="Button" />
</LinearLayout>
XML 2:
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="-11dp"
android:layout_y="-2dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="566dp"
android:layout_height="wrap_content"
android:layout_x="-14dp"
android:layout_y="-6dp"
android:src="@drawable/bear" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="566dp"
android:layout_height="wrap_content"
android:layout_x="-14dp"
android:layout_y="-6dp"
android:src="@drawable/fox" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="566dp"
android:layout_height="wrap_content"
android:layout_x="-14dp"
android:layout_y="-6dp"
android:src="@drawable/goat" />
</LinearLayout>
</HorizontalScrollView>
WEN我选择按钮2,IMAGEVIEW2应开通涡旋VIEW ...和文我选择按钮3,IMAGEVIEW3应开通...如何做到这一点? 亲切帮我解决这个问题....
你好,请避免CAPS,这是不好的。 –
@LeventeKurusa确实。但是,当你在它的时候,你也可以完全删除“请帮助”和类似的东西 - 从询问OP想要帮助的问题已经很明显了:7 –