Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8451755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:19:28+00:00 2026-06-10T11:19:28+00:00

i have a listactivity app , consist of 5 rows , each row cotain

  • 0

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 when you click any button it must open videoview screen , its work fine as image below :

enter image description here

But my issue is :

i can assign five different videos to be opend by the 5 buttons in each row .

what im trying to have different video for each button so :

25 button open 25 different videos .

which i mean:

button (one) in first row will open video_1

button (two) in first row will open video_2

button (three) in first row will open video_3

button (four) in first row will open video_4

button (five) in first row will open video_5

button (one) in second row will open video_6

button (two) in second row will open video_7

and so on till last button in fifth row

i cant achieve that .

any advice will be appreciated

THANKS

MY CODE :

ListButtons Class :

 public class ListButtons extends ListActivity {
String classes[] = {"First",  "Second", "Third","Fourth", "Fifth" }; 

@Override
protected void onCreate(Bundle savedInstanceState) {
    this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    setListAdapter(new MyArrayAdapter(this, classes));  }}

MyArrayAdapter Class :

 public class MyArrayAdapter extends ArrayAdapter<String> {

private final String[] mClasses;
private Context mContext;
private Typeface tf;
private LayoutInflater mInflater;
private String[] mData = { "button1", "button2", "button3", "button4",
        "button5" };
private int[] ids = { R.id.button1, R.id.button2, R.id.button3,
        R.id.button4, R.id.button5 };
int[][] rowDrawables = { 
        {R.drawable.row_1, R.drawable.row_2, R.drawable.row_3, 
             R.drawable.row_4, R.drawable.row_5},
        {R.drawable.row_6, R.drawable.row_7, R.drawable.row_8, 
             R.drawable.row_9, R.drawable.row_10},
        {R.drawable.row_11, R.drawable.row_12, R.drawable.row_13, 
             R.drawable.row_14, R.drawable.row_15},
        {R.drawable.row_16, R.drawable.row_17, R.drawable.row_18, 
             R.drawable.row_19, R.drawable.row_20},
        {R.drawable.row_21, R.drawable.row_22, R.drawable.row_23, 
             R.drawable.row_24, R.drawable.row_25}};

public MyArrayAdapter(Context context, String[] classes) {
    super(context, 0, classes);
    mClasses = classes;
    mContext = context;
    tf = Typeface.createFromAsset(context.getAssets(), "BFantezy.ttf");
    mInflater = LayoutInflater.from(context);
                              }

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.row, null, true);
        holder = new ViewHolder();
        holder.textView = (TextView) convertView
                .findViewById(R.id.row_label);
        holder.textView.setTypeface(tf);
        holder.bt1 = (Button) convertView.findViewById(R.id.button1);
        holder.bt2 = (Button) convertView.findViewById(R.id.button2);
        holder.bt3 = (Button) convertView.findViewById(R.id.button3);
        holder.bt4 = (Button) convertView.findViewById(R.id.button4);
        holder.bt5 = (Button) convertView.findViewById(R.id.button5);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    String s = mClasses[position];
    holder.textView.setText(s);

    int[] rowDr = rowDrawables[position];
    holder.bt1.setBackgroundResource(rowDr[0]);
    holder.bt2.setBackgroundResource(rowDr[1]);
    holder.bt3.setBackgroundResource(rowDr[2]);
    holder.bt4.setBackgroundResource(rowDr[3]);
    holder.bt5.setBackgroundResource(rowDr[4]);

    holder.textView.setTag(Integer.valueOf(position));
    holder.textView.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            Integer pos = (Integer) v.getTag();
            Intent ourIntent = new Intent(mContext, MyDay.class);
            ourIntent.putExtra("cheese", mClasses[pos]);
            mContext.startActivity(ourIntent);
                       }
                       });
    holder.bt1.setOnClickListener(mListener);
    holder.bt2.setOnClickListener(mListener);
    holder.bt3.setOnClickListener(mListener);
    holder.bt4.setOnClickListener(mListener);
    holder.bt5.setOnClickListener(mListener);
    return convertView;
                   }

static class ViewHolder {
    TextView textView;
    Button bt1, bt2, bt3, bt4, bt5;

                     }

private OnClickListener mListener = new OnClickListener() {

    public void onClick(View v) {
        String night = null;
        for (int i = 0; i < ids.length; i++) {
            if (v.getId() == ids[i]) {
                night = mData[i];
                break;
            }
        }
        Intent i = new Intent(mContext, My_videos.class);
        i.putExtra("video", night);
        mContext.startActivity(i);
                                   }
                                   };

                                }

My_videos Class :

  public class My_videos extends Activity {  
private VideoView vid;  
String night;  
/** Called when the activity is first created. */  
@Override  
public void onCreate(Bundle savedInstanceState) {   
    super.onCreate(savedInstanceState);   
    setContentView(R.layout.video); 

    Bundle bdl = getIntent().getExtras(); 
    night = bdl.getString("video");   
    vid = (VideoView) findViewById(R.id.videoView1); 

    if (night.equalsIgnoreCase("button1")) {    
    vid.setVideoURI(Uri.parse("android.resource://" + getPackageName()
                + "/" + R.raw.video_1));
        vid.setMediaController(new MediaController(My_videos.this));  
        vid.requestFocus();    
        vid.start(); }  

         else if (night.equalsIgnoreCase("button2")) {   
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                + "/" + R.raw.video_2)); 
         vid.setMediaController(new MediaController(My_videos.this));
             vid.requestFocus(); 
             vid.start(); } 

         else if (night.equalsIgnoreCase("button3")) { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                + "/" + R.raw.video_3)); 
         vid.setMediaController(new MediaController(My_videos.this));
             vid.requestFocus();
             vid.start();         } 
         else if (night.equalsIgnoreCase("button4")) { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                  + "/" + R.raw.video_4)); 
         vid.setMediaController(new MediaController(My_videos.this)); 
             vid.requestFocus();     
             vid.start(); }         
         else if (night.equalsIgnoreCase("button5")) {   
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName()  
                  + "/" + R.raw.video_5)); 
         vid.setMediaController(new MediaController(My_videos.this));   
             vid.requestFocus();      
             vid.start(); }  

                        }}       

UPDATE:

I try to modify the My_videos Class As below code but it end with shows same video for every button which is ( video_5 ) .

  public class My_videos extends Activity {  
private VideoView vid;  
String night;
private int position;  
/** Called when the activity is first created. */  
@Override  
public void onCreate(Bundle savedInstanceState) {   
    super.onCreate(savedInstanceState);   
    setContentView(R.layout.video); 

    Bundle bdl = getIntent().getExtras(); 
    night = bdl.getString("video");   
    vid = (VideoView) findViewById(R.id.videoView1); 


 if(position == 0){ 
        night.equalsIgnoreCase("button1"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                     + "/" + R.raw.video_1));
        vid.setMediaController(new MediaController(My_videos.this));
        vid.requestFocus();
        vid.start(); }      
          if(position == 0){ 
       night.equalsIgnoreCase("button2"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                   + "/" + R.raw.video_2));
        vid.setMediaController(new MediaController(My_videos.this));
        vid.requestFocus();
        vid.start(); }  }            
          if(position == 0){ 
        night.equalsIgnoreCase("button3"); { 
       vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                       + "/" + R.raw.video_3));
         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); } }                
     if(position == 0){ 
      night.equalsIgnoreCase("button4"); { 
         vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                     + "/" + R.raw.video_4));
         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); } }                    
      if(position == 0){ 
        night.equalsIgnoreCase("button5"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                    + "/" + R.raw.video_5));
         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); }}

else if(position == 1){ 
       night.equalsIgnoreCase("button1"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName()  
                   + "/" + R.raw.video_6));
         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); } }   
    if(position == 1){ 
         night.equalsIgnoreCase("button2"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                     + "/" + R.raw.video_7));
         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); } }            
    if(position == 1){ 
        night.equalsIgnoreCase("button3"); { 
         vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                       + "/" + R.raw.video_8));
              vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); } }                
    if(position == 1){ 
       night.equalsIgnoreCase("button4"); { 
         vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                     + "/" + R.raw.video_9));
         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); } }                    
    if(position == 1){ 
        night.equalsIgnoreCase("button5"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                   + "/" + R.raw.video_10));
         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); }}


 else if(position == 2){ 
        night.equalsIgnoreCase("button1"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                       + "/" + R.raw.video_11));
         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); }     }
    if(position == 2){ 
          night.equalsIgnoreCase("button2"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                 + "/" + R.raw.video_12));
         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); } }            
    if(position == 2){ 
        night.equalsIgnoreCase("button3"); { 
         vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                      + "/" + R.raw.video_13));
         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); }     }            
    if(position == 2){ 
         night.equalsIgnoreCase("button4"); { 
         vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                     + "/" + R.raw.video_14));
         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); } }                    
     if(position == 2){ 
      night.equalsIgnoreCase("button5"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                     + "/" + R.raw.video_15));
         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); }}

else if(position == 3){ 
      night.equalsIgnoreCase("button1"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                    + "/" + R.raw.video_16));
         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); } }   
      if(position == 3){ 
         night.equalsIgnoreCase("button2"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                      + "/" + R.raw.video_17));

               vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); } }            
      if(position == 3){ 
      night.equalsIgnoreCase("button3"); { 
         vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                 + "/" + R.raw.video_18));

             vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); } }                
      if(position == 3){ 
      night.equalsIgnoreCase("button4"); { 
         vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                         + "/" + R.raw.video_19));  

         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); } }                
      if(position == 3){ 
      night.equalsIgnoreCase("button5"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                       + "/" + R.raw.video_20));    

         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); }}             

 else if(position == 4){ 

    night.equalsIgnoreCase("button1"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                 + "/" + R.raw.video_21));
     vid.setMediaController(new MediaController(My_videos.this));
     vid.requestFocus();
     vid.start(); } }   
    if(position == 4){  

        night.equalsIgnoreCase("button2"); { 

    vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" 
               + R.raw.video_22));


                   vid.setMediaController(new MediaController(My_videos.this));
             vid.requestFocus();
         vid.start(); } }            
  if(position == 4){    

             night.equalsIgnoreCase("button3"); { 
         vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                    + "/" + R.raw.video_23));
                vid.setMediaController(new MediaController(My_videos.this));
          vid.requestFocus();
          vid.start(); }    }                
 if(position ==4){  
       night.equalsIgnoreCase("button4"); { 

        vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                  + "/" + R.raw.video_24));

         vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); } }

  if(position == 4){    
      night.equalsIgnoreCase("button5"); { 
     vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() 
                + "/" + R.raw.video_25));   

           vid.setMediaController(new MediaController(My_videos.this));
         vid.requestFocus();
         vid.start(); }}
              }}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:19:29+00:00Added an answer on June 10, 2026 at 11:19 am

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a listactivity app , each row cotain TEXT and BUTTON , both
I'm developing an app and I have one ListActivity , which has choice mode
I have an Android app with a ListActivity in the main view. The list
I have a ListActivity and I want to set programmatically the text of a
I have a ListView in a ListActivity populated with strings. However, only the text-part
in my app i have a list view. Each list consists of a image,
I am developing my first Android app. I have a ListActivity which uses the
I'm doing a simple quest app. Each quest consist of a checklist of things
i have this code: import android.app.Activity; import android.app.ListActivity; import android.os.Bundle; import android.widget.AdapterView; import android.widget.ArrayAdapter;
I'm having problems with my first Android app. I have subclassed ListActivity, and I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.