Listactivity With Multiple button and multiple videos

后端 未结 3 543
予麋鹿
予麋鹿 2021-01-26 18:12

i have a listactivity app , consist of 5 rows , each row cotain one TEXT and 5 BUTTON , both text and buttons are clickable , text will open MyDay activity whic is textview and

相关标签:
3条回答
  • 2021-01-26 18:34

    You get same video for all the ones, same video for all the twos so on, because you have the same ID for all the ones in all the rows and so on.

    So, do this in the onClick:

    public void onClick(View v) {
            String night = null;
            int position = yourListView.getPositionForView((View) v.getParent())
            for (int i = 0; i < ids.length; i++) {
                if (v.getId() == ids[i]) {
                    night = mData[i];
                    break;
                }
            }
    }
    

    now add this position also as an Extra to your intent. So that you will know which row's one is clicked and so on.

    0 讨论(0)
  • 2021-01-26 18:35

    At this link https://gist.github.com/3463215 I've posted a version of My_videos class that will do what you want. Basically, in the MyArrayAdapter class when a Button is clicked you will send in the Intent the row where that Button was clicked + the exact Button that was clicked in that row. Then in the My_videos class you'll get this numbers and easily find the correct video in an array of arrays data structure.

    0 讨论(0)
  • 2021-01-26 18:39

    You have 5 buttons, 25 links, 5 rows, And if u set 5 listener(for each button 1) u can select the uri like this ex:

    button1,button2,button3,button4,button5;
    
    button1.setOnclickListener(new View.onClickListener{
        public void onClick(View v){
            Integer pos = (Integer) v.getTag();
            Intent ourIntent = new Intent(mContext, MyDay.class);
            ourIntent.putExtra("cheese", mClasses[rowPosition*5+buttonPostion]);
            mContext.startActivity(ourIntent);
        }
    });
    

    rowPosition=in getView(position) is simple curent convertView number, button position is your your v.getTag() button number now is 1.

    Sow whit this u can select 25 link : exemple when u get onclick in your 2 row, 3rd button the link id will be 2*5+3=13 . so in your secund row the 3 buttom will get the 13 link to play.

    0 讨论(0)
提交回复
热议问题