Android微调器:已选择应用程序

Android微调器:已选择应用程序,android,spinner,Android,Spinner,我在将标题设置为自定义微调器时遇到了一个问题。点击后,任何项目都会因此错误而崩溃 08-04 02:48:39.490 16956-16956/com.example.ilija.festivalapp_makedox E/AndroidRuntime:致命异常:main 流程:com.example.ilija.festivalapp_makedox,PID:16956 java.lang.NullPointerException 在com.example.ilija.festivalapp_

我在将标题设置为自定义微调器时遇到了一个问题。点击后,任何项目都会因此错误而崩溃

08-04 02:48:39.490 16956-16956/com.example.ilija.festivalapp_makedox E/AndroidRuntime:致命异常:main 流程:com.example.ilija.festivalapp_makedox,PID:16956 java.lang.NullPointerException 在com.example.ilija.festivalapp_makedox.CustomSpinner$1.onItemSelected上(CustomSpinner.java:98) 在com.example.ilija.festivalapp_makedox.SpinnerPlus.setSelection上(SpinnerPlus.java:21) 在android.widget.Spinner$dropdownppopup$1.onItemClick(Spinner.java:1042) 在android.widget.AdapterView.performItemClick(AdapterView.java:299)上 在android.widget.AbsListView.performItemClick(AbsListView.java:1282)中 在android.widget.ListView.performItemClick(ListView.java:4450)上 在android.widget.AbsListView$PerformClick.run(AbsListView.java:3174)中 在android.widget.AbsListView$3.run(AbsListView.java:3925) 位于android.os.Handler.handleCallback(Handler.java:733) 位于android.os.Handler.dispatchMessage(Handler.java:95) 位于android.os.Looper.loop(Looper.java:157) 位于android.app.ActivityThread.main(ActivityThread.java:5872) 位于java.lang.reflect.Method.Invokenactive(本机方法) 位于java.lang.reflect.Method.invoke(Method.java:515) 在com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)上 位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674) 在dalvik.system.NativeStart.main(本机方法)

CustomSpinner.java:

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom_spinner);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle("Movies");
        setSupportActionBar(toolbar);
        activity = this;
        SpinnerPlus SpinnerExample = (SpinnerPlus) findViewById(R.id.spinner);
        SpinnerPlus SpinnerExample1 = (SpinnerPlus) findViewById(R.id.spinner1);
        SpinnerPlus SpinnerExample2 = (SpinnerPlus) findViewById(R.id.spinner2);
        SpinnerPlus SpinnerExample3 = (SpinnerPlus) findViewById(R.id.spinner3);
         SpinnerPlus SpinnerExampleTest = (SpinnerPlus) findViewById(R.id.spinnerTest);
      /*   Spinner SpinnerExampleTest = (Spinner) findViewById(R.id.spinnerTest);
        Spinner SpinnerExampleTest1 = (Spinner) findViewById(R.id.spinner1Test);
        Spinner SpinnerExampleTest2 = (Spinner) findViewById(R.id.spinner2Test);
        Spinner SpinnerExampleTest3 = (Spinner) findViewById(R.id.spinner3Test);*/
        output = (TextView)findViewById(R.id.output);

        setListData();
        setListData1();
        setListData2();
        setListData3();

        setListDataTest();
       /* setListData1Test();
        setListData2Test();
        setListData3Test();*/

        Resources res = getResources();
        adapter = new CustomAdapter(activity,R.layout.spinner_rows,CustomListViewValuesArr,res);
        adapter1 = new CustomAdapter(activity,R.layout.spinner_rows,CustomListViewValuesArr1,res);
        adapter2 = new CustomAdapter(activity,R.layout.spinner_rows,CustomListViewValuesArr2,res);
        adapter3 = new CustomAdapter(activity,R.layout.spinner_rows,CustomListViewValuesArr3,res);

         adapterTest = new CustomAdapter(activity,R.layout.spinner_rows,CustomListViewValuesArrTest,res);
       /*adapter1Test = new CustomAdapter(activity,R.layout.spinner_rows,CustomListViewValuesArr1Test,res);
        adapter2Test = new CustomAdapter(activity,R.layout.spinner_rows,CustomListViewValuesArr2Test,res);
        adapter3Test = new CustomAdapter(activity,R.layout.spinner_rows,CustomListViewValuesArr3Test,res);*/

        adapter.setDropDownViewResource(R.layout.spinner_rows);
        SpinnerExample.setPrompt("Select your favorite Planet!");

        SpinnerExample.setAdapter(
                new NothingSelectedSpinnerAdapter(
                        adapter,
                        R.layout.contact_spinner_row_nothing_selected,
                        // R.layout.contact_spinner_nothing_selected_dropdown, // Optional
                        this));

        SpinnerExample.setOnItemSelectedEvenIfUnchangedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
              //  i++;  //Avoid fist time oppening the OnClick start new intent. First time is for set pic of the first element in the list.
                String Movie = ((TextView) view.findViewById(R.id.movieName)).getText().toString();
               // if(i>=1){
                    Intent intent = new Intent(CustomSpinner.this, MovieTrailer.class);
                    if(position==0) {
                        intent.putExtra("Cartoons","10");
                    } else if(position==1) {
                        intent.putExtra("Cartoons","11");
                    } else if(position==2) {
                        intent.putExtra("Cartoons","12");
                    } else if(position==3) {
                        intent.putExtra("Cartoons","13");
                    } else if(position==4) {
                        intent.putExtra("Cartoons","14");
                    } else if(position==5) {
                        intent.putExtra("Cartoons","15");
                    } else if(position==6) {
                        intent.putExtra("Cartoons","16");
                    } else if(position==7) {
                        intent.putExtra("Cartoons","17");
                    } else if(position==8) {
                        intent.putExtra("Cartoons","18");
                    }
                    startActivity(intent);
                //}
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });


       SpinnerExample1.setAdapter(adapter1);
        SpinnerExample1.setOnItemSelectedEvenIfUnchangedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
               // i++;  //Avoid fist time oppening the OnClick start new intent. First time is for set pic of the first element in the list.
                String Movie = ((TextView) view.findViewById(R.id.movieName)).getText().toString();
             //   if(i>2){
                    Intent intent = new Intent(CustomSpinner.this, MovieTrailer.class);
                    if(position==0) {
                        intent.putExtra("Cartoons","20");
                    } else if(position==1) {
                        intent.putExtra("Cartoons","21");
                    } else if(position==2) {
                        intent.putExtra("Cartoons","22");
                    } else if(position==3) {
                        intent.putExtra("Cartoons","23");
                    } else if(position==4) {
                        intent.putExtra("Cartoons","24");
                    } else if(position==5) {
                        intent.putExtra("Cartoons","25");
                    } else if(position==6) {
                        intent.putExtra("Cartoons","26");
                    } else if(position==7) {
                        intent.putExtra("Cartoons","27");
                    } else if(position==8) {
                        intent.putExtra("Cartoons","28");
                    }
                    startActivity(intent);
               // }
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
SpinnerPlus.java:

import android.content.Context;
import android.util.AttributeSet;
import android.widget.AdapterView;
import android.widget.Spinner;

import java.lang.reflect.Field;

public class SpinnerPlus extends Spinner {
    AdapterView.OnItemSelectedListener listener;

    public SpinnerPlus(Context context, AttributeSet attrs) {
        super(context,attrs);
    }

    @Override
    public void setSelection(int position) {
        super.setSelection(position);
        if (listener != null)
            listener.onItemSelected(this, getSelectedView(), position, 0);
    }

    public void setOnItemSelectedEvenIfUnchangedListener(
            AdapterView.OnItemSelectedListener listener) {
        this.listener = listener;
    }
}
CustomAdapter.java

package com.example.ilija.festivalapp_makedox;

import android.content.Context;
import android.database.DataSetObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.SpinnerAdapter;

/**
 * Decorator Adapter to allow a Spinner to show a 'Nothing Selected...' initially
 * displayed instead of the first choice in the Adapter.
 */
public class NothingSelectedSpinnerAdapter implements SpinnerAdapter, ListAdapter {

    protected static final int EXTRA = 1;
    protected SpinnerAdapter adapter;
    protected Context context;
    protected int nothingSelectedLayout;
    protected int nothingSelectedDropdownLayout;
    protected LayoutInflater layoutInflater;

    /**
     * Use this constructor to have NO 'Select One...' item, instead use
     * the standard prompt or nothing at all.
     * @param spinnerAdapter wrapped Adapter.
     * @param nothingSelectedLayout layout for nothing selected, perhaps
     * you want text grayed out like a prompt...
     * @param context
     */
    public NothingSelectedSpinnerAdapter(
            SpinnerAdapter spinnerAdapter,
            int nothingSelectedLayout, Context context) {

        this(spinnerAdapter, nothingSelectedLayout, -1, context);
    }

    /**
     * Use this constructor to Define your 'Select One...' layout as the first
     * row in the returned choices.
     * If you do this, you probably don't want a prompt on your spinner or it'll
     * have two 'Select' rows.
     * @param spinnerAdapter wrapped Adapter. Should probably return false for isEnabled(0)
     * @param nothingSelectedLayout layout for nothing selected, perhaps you want
     * text grayed out like a prompt...
     * @param nothingSelectedDropdownLayout layout for your 'Select an Item...' in
     * the dropdown.
     * @param context
     */
    public NothingSelectedSpinnerAdapter(SpinnerAdapter spinnerAdapter,
                                         int nothingSelectedLayout, int nothingSelectedDropdownLayout, Context context) {
        this.adapter = spinnerAdapter;
        this.context = context;
        this.nothingSelectedLayout = nothingSelectedLayout;
        this.nothingSelectedDropdownLayout = nothingSelectedDropdownLayout;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public final View getView(int position, View convertView, ViewGroup parent) {
        // This provides the View for the Selected Item in the Spinner, not
        // the dropdown (unless dropdownView is not set).
        if (position == 0) {
            return getNothingSelectedView(parent);
        }
        return adapter.getView(position - EXTRA, null, parent); // Could re-use
        // the convertView if possible.
    }

    /**
     * View to show in Spinner with Nothing Selected
     * Override this to do something dynamic... e.g. "37 Options Found"
     * @param parent
     * @return
     */
    protected View getNothingSelectedView(ViewGroup parent) {
        return layoutInflater.inflate(nothingSelectedLayout, parent, false);
    }

    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
        // Android BUG! http://code.google.com/p/android/issues/detail?id=17128 -
        // Spinner does not support multiple view types
        if (position == 0) {
            return nothingSelectedDropdownLayout == -1 ?
                    new View(context) :
                    getNothingSelectedDropdownView(parent);
        }

        // Could re-use the convertView if possible, use setTag...
        return adapter.getDropDownView(position - EXTRA, null, parent);
    }

    /**
     * Override this to do something dynamic... For example, "Pick your favorite
     * of these 37".
     * @param parent
     * @return
     */
    protected View getNothingSelectedDropdownView(ViewGroup parent) {
        return layoutInflater.inflate(nothingSelectedDropdownLayout, parent, false);
    }

    @Override
    public int getCount() {
        int count = adapter.getCount();
        return count == 0 ? 0 : count + EXTRA;
    }

    @Override
    public Object getItem(int position) {
        return position == 0 ? null : adapter.getItem(position - EXTRA);
    }

    @Override
    public int getItemViewType(int position) {
        return 0;
    }

    @Override
    public int getViewTypeCount() {
        return 1;
    }

    @Override
    public long getItemId(int position) {
        return position >= EXTRA ? adapter.getItemId(position - EXTRA) : position - EXTRA;
    }

    @Override
    public boolean hasStableIds() {
        return adapter.hasStableIds();
    }

    @Override
    public boolean isEmpty() {
        return adapter.isEmpty();
    }

    @Override
    public void registerDataSetObserver(DataSetObserver observer) {
        adapter.registerDataSetObserver(observer);
    }

    @Override
    public void unregisterDataSetObserver(DataSetObserver observer) {
        adapter.unregisterDataSetObserver(observer);
    }

    @Override
    public boolean areAllItemsEnabled() {
        return false;
    }

    @Override
    public boolean isEnabled(int position) {
        return position != 0; // Don't allow the 'nothing selected'
        // item to be picked.
    }

}
package com.example.ilija.festivalapp_makedox;

import android.app.Activity;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.ArrayList;

/**
 * Created by ilija on 15-Jul-16.
 */

public class CustomAdapter extends ArrayAdapter<String>{

    private Activity activity;
    private ArrayList data;
    public Resources res;
    SpinnerModel tempValues=null;
    LayoutInflater inflater;

    public CustomAdapter(
            CustomSpinner activitySpinner,
            int textViewResourceId,
            ArrayList objects,
            Resources resLocal
    ) {
        super(activitySpinner, textViewResourceId, objects);
                    activity = activitySpinner;
                    data = objects;
                    res=resLocal;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public View getDropDownView(int position, View convertView, ViewGroup parent){
            return getCustomView(position,convertView,parent);
    }

        public View getView(int position, View convertView, ViewGroup parent){
            return getCustomView(position,convertView,parent);
        }



    public View getCustomView(int position, View convertView, ViewGroup parent){
        View row = inflater.inflate(R.layout.spinner_rows, parent, false);
        tempValues = null;
        tempValues = (SpinnerModel) data.get(position);

        TextView label = (TextView)row.findViewById(R.id.movieName);
        ImageView image = (ImageView)row.findViewById(R.id.imageSpinner);
        RelativeLayout backgorund = (RelativeLayout)row.findViewById(R.id.spinnerBackground);
        label.setText(tempValues.getMovieName());
        image.setImageResource(res.getIdentifier("com.example.ilija.festivalapp_makedox:drawable/"+tempValues.getImage(),null,null));
        //backgorund.setBackgroundColor(tempValues.getBackground());
        return row;
    }
}
package com.example.ilija.festivalapp\u makedox;
导入android.app.Activity;
导入android.graphics.Color;
导入android.view.view;
导入android.view.ViewGroup;
导入android.content.Context;
导入android.content.res.Resources;
导入android.view.LayoutInflater;
导入android.widget.ArrayAdapter;
导入android.widget.ImageView;
导入android.widget.RelativeLayout;
导入android.widget.TextView;
导入java.util.ArrayList;
/**
*伊利亚于2016年7月15日创作。
*/
公共类CustomAdapter扩展了ArrayAdapter{
私人活动;
私有数组列表数据;
公共资源;
SpinnerModel tempValues=null;
充气机;
公共自定义适配器(
自定义微调器活动微调器,
int textViewResourceId,
ArrayList对象,
本地资源
) {
超级(activitySpinner、textViewResourceId、对象);
活动=活动微调器;
数据=对象;
res=resLocal;
充气器=(LayoutInflater)activity.getSystemService(Context.LAYOUT\u充气器\u SERVICE);
}
公共视图getDropDownView(int位置、视图转换视图、视图组父视图){
返回getCustomView(位置、转换视图、父级);
}
公共视图getView(int位置、视图转换视图、视图组父视图){
返回getCustomView(位置、转换视图、父级);
}
公共视图getCustomView(int位置、视图转换视图、视图组父视图){
视图行=充气器。充气(R.layout.spinner\u行,父,false);
tempValues=null;
tempValues=(喷丝头模型)data.get(位置);
TextView标签=(TextView)row.findViewById(R.id.movieName);
ImageView image=(ImageView)row.findViewById(R.id.imageSpinner);
RelativeLayout backgorund=(RelativeLayout)row.findViewById(R.id.spinnerBackground);
label.setText(tempValues.getMovieName());
setImageResource(res.getIdentifier(“com.example.ilija.festivalapp_makedox:drawable/”+tempValues.getImage(),null,null));
//backgound.setBackgroundColor(tempValues.getBackground());
返回行;
}
}
活动\自定义\微调器.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:agendaCalendar="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".MainScreen">


    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">
        <!--tools:context=".MainScreen"-->

        <android.support.design.widget.CoordinatorLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
            android:layout_height="match_parent" android:fitsSystemWindows="true"
            tools:context=".MainScreen">

            <android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
                android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay">

                <android.support.v7.widget.Toolbar android:id="@+id/toolbar"
                    android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
                    android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" />

            </android.support.design.widget.AppBarLayout>

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:layout_marginTop="55dp"
                android:id="@+id/imageView2"
                android:layout_alignParentTop="true"
                android:background="@drawable/makecover"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"/>



        <ScrollView
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="155dp"
            android:layout_marginBottom="10dp"
            android:fillViewport="true"
            >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="11dp"
            android:layout_marginRight="11dp"
            android:orientation="vertical"
            >
                <TextView
                    android:id="@+id/ico"
                    android:text="SELECTIONS:"
                    android:paddingTop="10dp"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:paddingLeft="1dp" />
                <TextView
                    android:id="@+id/ico1"
                    android:text="INTERNATIONAL COMPETITION"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:paddingLeft="1dp"
                    android:paddingTop="5dp"/>
                <com.example.ilija.festivalapp_makedox.SpinnerPlus
                    android:id="@+id/spinner"
                    android:background="@color/main_competition"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"/>
                <TextView
                    android:id="@+id/ico2"
                    android:text="NEWCOMERS COMPETITION"
                    android:paddingLeft="1dp"
                    android:paddingTop="5dp"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" />
          <!--      <com.example.ilija.festivalapp_makedox.SpinnerPlus
                    android:id="@+id/spinner1"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"/>-->
            <com.example.ilija.festivalapp_makedox.SpinnerPlus
                android:id="@+id/spinner1"
                android:background="@color/newcomers"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                />
                <TextView
                    android:id="@+id/ico3"
                    android:text="FOCUS RUSSIA"
                    android:paddingLeft="1dp"
                    android:paddingTop="5dp"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" />
                <com.example.ilija.festivalapp_makedox.SpinnerPlus
                    android:id="@+id/spinner2"
                    android:background="@color/russian"
                    android:spinnerMode="dropdown"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"/>

                <TextView
                    android:id="@+id/ico4"
                    android:text="SHORT DOX"
                    android:paddingLeft="1dp"
                    android:paddingTop="5dp"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" />
                <com.example.ilija.festivalapp_makedox.SpinnerPlus
                    android:id="@+id/spinner3"
                    android:background="@color/short1"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"/>

                 <TextView
                    android:id="@+id/spinnerTesttxt"
                    android:text="STUDENT DOX"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:paddingLeft="1dp"
                    android:paddingTop="5dp"/>
                <com.example.ilija.festivalapp_makedox.SpinnerPlus
                    android:id="@+id/spinnerTest"
                    android:background="@color/student"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"/>
            <!--<TextView
                 android:id="@+id/ico2spinnerTest"
                 android:text="ActionSpinnerTest:"
                 android:paddingLeft="10dp"
                 android:paddingTop="5dp"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content" />
             <Spinner
                 android:id="@+id/spinner1Test"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"/>
             <TextView
                 android:id="@+id/ico3spinnerTest"
                 android:text="HorrorspinnerTest:"
                 android:paddingLeft="10dp"
                 android:paddingTop="5dp"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content" />
             <Spinner
                 android:id="@+id/spinner2Test"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"/>

             <TextView
                 android:id="@+id/ico4spinnerTest"
                 android:text="CartoonspinnerTest:"
                 android:paddingLeft="10dp"
                 android:paddingTop="5dp"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content" />
             <Spinner
                 android:id="@+id/spinner3Test"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"/>-->
        </LinearLayout>
    </ScrollView>

    <include layout="@layout/content_custom_spinner" />

        </android.support.design.widget.CoordinatorLayout>

        <android.support.design.widget.NavigationView android:id="@+id/nav_view"
            android:layout_width="wrap_content" android:layout_height="match_parent"
            android:layout_gravity="start" android:fitsSystemWindows="true"
            app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" />

    </android.support.v4.widget.DrawerLayout>


</RelativeLayout>

可以是
((TextView)view.findViewById(R.id.movieName)).getText().toString()为空。拿着你的绳子
SpinnerExample.setOnItemSelectedEvenIfUnchangedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
              //  i++;  //Avoid fist time oppening the OnClick start new intent. First time is for set pic of the first element in the list.
                String Movie = (String) CustomListViewValuesArr1.get(postion)
               // if(i>=1){
                    Intent intent = new Intent(CustomSpinner.this, MovieTrailer.class);
                    if(position==0) {
                        intent.putExtra("Cartoons","10");
                    } else if(position==1) {
                        intent.putExtra("Cartoons","11");
                    } else if(position==2) {
                        intent.putExtra("Cartoons","12");
                    } else if(position==3) {
                        intent.putExtra("Cartoons","13");
                    } else if(position==4) {
                        intent.putExtra("Cartoons","14");
                    } else if(position==5) {
                        intent.putExtra("Cartoons","15");
                    } else if(position==6) {
                        intent.putExtra("Cartoons","16");
                    } else if(position==7) {
                        intent.putExtra("Cartoons","17");
                    } else if(position==8) {
                        intent.putExtra("Cartoons","18");
                    }
                    startActivity(intent);
                //}
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });