Воспроизвести видео при нажатии на элемент списка - PullRequest
0 голосов
/ 24 февраля 2012

У меня есть список, созданный из нескольких тем для создаваемого приложения, но он мне нужен, поэтому, когда пользователь нажимает на элемент списка, он открывает видео

У меня есть

public class Intro extends ListActivity {

String classes[] = { "Name", "Age", "From", "Feeling"};

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

    setListAdapter(new ArrayAdapter<String>(Intro.this,
            android.R.layout.simple_list_item_1, classes));
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    // TODO Auto-generated method stub
    super.onListItemClick(l, v, position, id);
    String cheese = classes[position];
    try {
        Class ourClass = Class.forName("com.IrishSign.app." + cheese);
        Intent ourIntent = new Intent(Intro.this, ourClass);
        startActivity(ourIntent);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}

}

и

public class Age extends Activity  
{  
    private VideoView vView;  

    /** Called when the activity is first created. */  
    @Override  
    public void onCreate(Bundle savedInstanceState)  
    {  
       //sets the Bundle  
       super.onCreate(savedInstanceState);  
       //sets the context  
       setContentView(R.layout.main);  

       //get the VideoView from the layout file  
       vView = (VideoView)findViewById(R.id.vidview1);  

       //use this to get touch events  
       vView.requestFocus(); }

       private String vSource;  

       public void onCreate1(Bundle savedInstanceState)  
       {  
        //...  

        //replace line 23 with these lines of code  
        //loads video from the Resources folder  
        //set the video path  
        vSource ="android.resource://com.IrishSign.app/" + R.raw.age;  
        //set the video URI, passing the vSourse as a URI  
        vView.setVideoURI(Uri.parse(vSource));  

        //...  
        }  
{

    //enable this if you want to enable video controllers, such as pause and forward  
    vView.setMediaController(new MediaController(this));  

    //plays the movie  
    vView.start();  
} 

}

Когда я отлаживаю приложение, я получаю Источник не найден . У вас есть идеи о том, что не так?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...