卡住尝试链接页面

时间:2019-05-05 14:15:39

标签: java android-layout

我在第一页上工作了,但第二页上有youtube教程,但是似乎无法按照我想要的方式工作。页面的处理方式有所不同。

这是工作页面

private void setSingleEvent(GridLayout mainGrid) {
            //Loop all child item of Main Grid
            for (int i = 0; i < mainGrid.getChildCount(); i++) {
                //You can see , all child item is CardView , so we just cast object to CardView
                CardView cardView = (CardView) mainGrid.getChildAt(i);
                final int finalI = i;
                cardView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                       if (finalI == 0) // open page 1
                       {
                           Intent intent = new Intent (MainActivity.this, StarterVapes.class);
                           startActivity(intent);
                       }

                       else if (finalI == 1) // open page 2
                        {
                            Intent intent = new Intent (MainActivity.this, UpgradeVapes.class);
                            startActivity(intent);
                        }


这是无效页面

@Override
    public void onBindViewHolder(final ViewHolder viewHolder, final int i) {

        viewHolder.imgView.setImageResource(imagesList.get(i));
        viewHolder.txtTitle.setText(titleList.get(i));
        final int finalI = i;
        viewHolder.parentLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {


                if (finalI == 0) // open page 1
                {
                    Intent intent = new Intent (context, AboutUS.class);
                    context.startActivity(intent);
                }

                else if (finalI == 1) // open page 2
                {
                    Intent intent = new Intent (context.this, AboutUS.class);
                    context.startActivity(intent);
                }

              //  Intent intent = new Intent(context, DetailActivity.class);
              //  intent.putExtra("title", titleList.get(i));
              //  context.startActivity(intent);
            }
        });

我希望它是您单击进入页面的第一个图块,然后单击进入另一个页面的第二个图块,依此类推。

1 个答案:

答案 0 :(得分:0)

abs(x - 8)

标题

          Got it working