我有一個關於圖片點擊問題的問題:關於圖片點擊問題
我使用了粘粘的視差效果,在此我Viewpager
是不工作的點擊。 我的要求是,如果用戶點擊,那麼他應該重定向到另一個頁面。我正在使用this鏈接。
我使用Viewpager而不是Imageview,而Viewpager有一些圖像滑動。 多數民衆贊成沒有Working.I得到一個數組的圖像。
任何想法,我錯了嗎?
謝謝。
My Code:
public class MainActivity extends ActionBarActivity {
private TextView stickyView;
private ListView listView;
private View heroImageView;
private View stickyViewSpacer;
private int MAX_ROWS = 20;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/* Initialise list view, hero image, and sticky view */
listView = (ListView) findViewById(R.id.listView);
heroImageView = findViewById(R.id.heroImageView);
stickyView = (TextView) findViewById(R.id.stickyView);
heroImageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(CollectionDetailActivity.this, "click", Toast.LENGTH_SHORT).show();
}
});
/* Inflate list header layout */
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View listHeader = inflater.inflate(R.layout.list_header, null);
stickyViewSpacer = listHeader.findViewById(R.id.stickyViewPlaceholder);
/* Add list view header */
listView.addHeaderView(listHeader);
/* Handle list View scroll events */
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
/* Check if the first item is already reached to top.*/
if (listView.getFirstVisiblePosition() == 0) {
View firstChild = listView.getChildAt(0);
int topY = 0;
if (firstChild != null) {
topY = firstChild.getTop();
}
int heroTopY = stickyViewSpacer.getTop();
stickyView.setY(Math.max(0, heroTopY + topY));
/* Set the image to scroll half of the amount that of ListView */
heroImageView.setY(topY * 0.5f);
}
}
});
/* Populate the ListView with sample data */
List<String> modelList = new ArrayList<>();
for (int i = 0; i < MAX_ROWS; i++) {
modelList.add("List item " + i);
}
ArrayAdapter adapter = new ArrayAdapter(this, R.layout.list_row, modelList);
listView.setAdapter(adapter);
}
}
你加點擊事件Imageview? –
是的,我認爲它的效果就是爲什麼它不點擊 –
在這裏發表你的代碼。 –