android - Spinners with Tabbed Activity [duplicate]
This question already has an answer here:
findViewById() returns null when I call it in onCreate()
3 answers
What is a NullPointerException, and how do I fix it?
12 answers
I'm working on android app, I used Tabbed Activity then added Spinner which contains String Array, but I think there's some issues with the ArrayAdapter.
Everytime I set adapter to my spinner and debug app, it crashes and gives me exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
Here is my code:
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/relative"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.expresshub.MainActivity"
tools:showIn="@layout/activity_main">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinner"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:spinnerMode="dialog" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinner2"
android:layout_below="@+id/spinner"
android:layout_centerHorizontal="true" />
</RelativeLayout>
in MainActivity.java
public class MainActivity extends AppCompatActivity {
/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a
* {@link FragmentPagerAdapter} derivative, which will keep every
* loaded fragment in memory. If this becomes too memory intensive, it
* may be best to switch to a
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/
private SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
private ViewPager mViewPager;
public Spinner spinner1, spinner2;
public String countries = {"აირჩიეთ გამგზავნი ქვეყანა", "საქართველო", "ავსტრალია",
"ავსტრია", "ავღანეთი", "აზერბაიჯანი", "ალბანეთი", "ალჟირი", "ა.შ.შ",
"არაბთა გაერთიანებული საამიროები", "არგენტინა", "ახალი ზელანდია",
"ბანგლადეში", "ბაჰრეინი", "ბელორუსი", "ბელგია", "ბოლივია",
"ბრაზილია", "ბულგარეთი", "გერმანია", "გვადალუპა", "გრენლანდია", "დანია",
"დიდი ბრიტანეთი", "ეგვიპტე", "ეთიოპია", "ერაყი", "ესპანეთი", "ესტონეთი",
"ვენესუელა", "ვიეტნამი", "ზიმბაბვე", "თურქეთი", "თურქმენეთი", "იაპონია", "ინდოეთი",
"ინდონეზია", "ირანი", "ირლანდია", "ისლანდია", "ისრაელი", "იტალია", "კანადა",
"კატარი", "კვიპროსი", "კოლუმბია", "კორეა", "კუბა", "ლაოსი", "ლატვია", "ლიბია",
"ლიტვა", "ლუქსემბურგი", "მადაგასკარი", "მაკედონია", "მალაიზია", "მალდივი",
"მალტა", "მაროკო", "მექსიკა", "მოლდოვა", "მონაკო", "მონღოლეთი", "ნეპალი",
"ნიგერია", "ნიდერლანდი", "ნორვეგია", "ომანი", "პაკისტანი", "პანამა", "პარაგვაი",
"პერუ", "პოლონეთი", "პორტუგალია", "პუერტო-რიკო", "რუმინეთი", "რუსეთი",
"საბერძნეთი", "სალვადორი", "სამხრეთ აფრიკის რესპუბლიკა", "საუდის არაბეთი",
"საფრანგეთი", "სერბეთი", "სინგაპური", "სირია", "სლოვაკეთი", "სლოვენია", "სომხეთი",
"სუდანი", "ტაივანი", "ტაილანდი", "ტუნისი", "უზბეკეთი", "უკრაინა", "უნგრეთი",
"ფილიპინები", "ფინეთი", "ქუვეითი", "ყაზახეთი", "შვეიცარია", "შვედეთი", "ჩეხეთი",
"ჩილე", "ჩინეთი", "ხორვატია", "ჰონკონგი"};
public int lisimages = {R.drawable.dhl, R.drawable.fedex, R.drawable.ups, R.drawable.tnt, R.drawable.gpost};
public String days = {"სატრანზიტო ვადა 1-3 დღე", "1-2 დღე", "სატრანზიტო ვადა 3-5 დღე",
"სატრანზიტო ვადა 5-7 დღე", "სატრანზიტო ვადა 6-8 დღე",
"სატრანზიტო ვადა 2-4 დღე", "სატრანზიტო ვადა 10-20 დღე",
"სატრანზიტო ვადა 15-30 დღე"};
public String companies = {"DHL Global Forwarding", "FedEx Express",
"TNT Express", "UPS Express",
"საქართველოს ფოსტის EMS", "საქართველოს ფოსტა"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Views
spinner1 = (Spinner) findViewById(R.id.spinner);
spinner2 = (Spinner) findViewById(R.id.spinner2);
// Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
// My code
ArrayAdapter<String> arr = new ArrayAdapter<String>(this, R.layout.support_simple_spinner_dropdown_item, countries);
spinner1.setAdapter(arr);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
public PlaceholderFragment() {
}
/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.tab1, container, false);
return rootView;
}
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below).
return PlaceholderFragment.newInstance(position + 1);
}
@Override
public int getCount() {
// Show 3 total pages.
return 3;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "საერთაშორისო გზავნილები";
case 1:
return "ქვეყნის შიდა გზავნილები";
case 2:
return "ამანათების ჩამოტანა";
}
return null;
}
}
}
Logcat:
11-23 20:53:48.769 12434-12434/com.expresshub E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.expresshub, PID: 12434
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.expresshub/com.expresshub.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Spinner.setAdapter(android.widget.SpinnerAdapter)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$1100(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Spinner.setAdapter(android.widget.SpinnerAdapter)' on a null object reference
at com.expresshub.MainActivity.onCreate(MainActivity.java:117)
at android.app.Activity.performCreate(Activity.java)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$1100(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
java android nullpointerexception android-spinner android-tabbed-activity
marked as duplicate by Mike M.
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 17:22
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
|
show 14 more comments
This question already has an answer here:
findViewById() returns null when I call it in onCreate()
3 answers
What is a NullPointerException, and how do I fix it?
12 answers
I'm working on android app, I used Tabbed Activity then added Spinner which contains String Array, but I think there's some issues with the ArrayAdapter.
Everytime I set adapter to my spinner and debug app, it crashes and gives me exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
Here is my code:
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/relative"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.expresshub.MainActivity"
tools:showIn="@layout/activity_main">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinner"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:spinnerMode="dialog" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinner2"
android:layout_below="@+id/spinner"
android:layout_centerHorizontal="true" />
</RelativeLayout>
in MainActivity.java
public class MainActivity extends AppCompatActivity {
/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a
* {@link FragmentPagerAdapter} derivative, which will keep every
* loaded fragment in memory. If this becomes too memory intensive, it
* may be best to switch to a
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/
private SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
private ViewPager mViewPager;
public Spinner spinner1, spinner2;
public String countries = {"აირჩიეთ გამგზავნი ქვეყანა", "საქართველო", "ავსტრალია",
"ავსტრია", "ავღანეთი", "აზერბაიჯანი", "ალბანეთი", "ალჟირი", "ა.შ.შ",
"არაბთა გაერთიანებული საამიროები", "არგენტინა", "ახალი ზელანდია",
"ბანგლადეში", "ბაჰრეინი", "ბელორუსი", "ბელგია", "ბოლივია",
"ბრაზილია", "ბულგარეთი", "გერმანია", "გვადალუპა", "გრენლანდია", "დანია",
"დიდი ბრიტანეთი", "ეგვიპტე", "ეთიოპია", "ერაყი", "ესპანეთი", "ესტონეთი",
"ვენესუელა", "ვიეტნამი", "ზიმბაბვე", "თურქეთი", "თურქმენეთი", "იაპონია", "ინდოეთი",
"ინდონეზია", "ირანი", "ირლანდია", "ისლანდია", "ისრაელი", "იტალია", "კანადა",
"კატარი", "კვიპროსი", "კოლუმბია", "კორეა", "კუბა", "ლაოსი", "ლატვია", "ლიბია",
"ლიტვა", "ლუქსემბურგი", "მადაგასკარი", "მაკედონია", "მალაიზია", "მალდივი",
"მალტა", "მაროკო", "მექსიკა", "მოლდოვა", "მონაკო", "მონღოლეთი", "ნეპალი",
"ნიგერია", "ნიდერლანდი", "ნორვეგია", "ომანი", "პაკისტანი", "პანამა", "პარაგვაი",
"პერუ", "პოლონეთი", "პორტუგალია", "პუერტო-რიკო", "რუმინეთი", "რუსეთი",
"საბერძნეთი", "სალვადორი", "სამხრეთ აფრიკის რესპუბლიკა", "საუდის არაბეთი",
"საფრანგეთი", "სერბეთი", "სინგაპური", "სირია", "სლოვაკეთი", "სლოვენია", "სომხეთი",
"სუდანი", "ტაივანი", "ტაილანდი", "ტუნისი", "უზბეკეთი", "უკრაინა", "უნგრეთი",
"ფილიპინები", "ფინეთი", "ქუვეითი", "ყაზახეთი", "შვეიცარია", "შვედეთი", "ჩეხეთი",
"ჩილე", "ჩინეთი", "ხორვატია", "ჰონკონგი"};
public int lisimages = {R.drawable.dhl, R.drawable.fedex, R.drawable.ups, R.drawable.tnt, R.drawable.gpost};
public String days = {"სატრანზიტო ვადა 1-3 დღე", "1-2 დღე", "სატრანზიტო ვადა 3-5 დღე",
"სატრანზიტო ვადა 5-7 დღე", "სატრანზიტო ვადა 6-8 დღე",
"სატრანზიტო ვადა 2-4 დღე", "სატრანზიტო ვადა 10-20 დღე",
"სატრანზიტო ვადა 15-30 დღე"};
public String companies = {"DHL Global Forwarding", "FedEx Express",
"TNT Express", "UPS Express",
"საქართველოს ფოსტის EMS", "საქართველოს ფოსტა"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Views
spinner1 = (Spinner) findViewById(R.id.spinner);
spinner2 = (Spinner) findViewById(R.id.spinner2);
// Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
// My code
ArrayAdapter<String> arr = new ArrayAdapter<String>(this, R.layout.support_simple_spinner_dropdown_item, countries);
spinner1.setAdapter(arr);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
public PlaceholderFragment() {
}
/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.tab1, container, false);
return rootView;
}
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below).
return PlaceholderFragment.newInstance(position + 1);
}
@Override
public int getCount() {
// Show 3 total pages.
return 3;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "საერთაშორისო გზავნილები";
case 1:
return "ქვეყნის შიდა გზავნილები";
case 2:
return "ამანათების ჩამოტანა";
}
return null;
}
}
}
Logcat:
11-23 20:53:48.769 12434-12434/com.expresshub E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.expresshub, PID: 12434
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.expresshub/com.expresshub.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Spinner.setAdapter(android.widget.SpinnerAdapter)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$1100(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Spinner.setAdapter(android.widget.SpinnerAdapter)' on a null object reference
at com.expresshub.MainActivity.onCreate(MainActivity.java:117)
at android.app.Activity.performCreate(Activity.java)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$1100(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
java android nullpointerexception android-spinner android-tabbed-activity
marked as duplicate by Mike M.
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 17:22
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Please edit your question to add the complete stack trace, and the parts of your code that it references.
– Mike M.
Nov 23 '18 at 16:19
which line exception occurs? And post all code please.
– Augusto
Nov 23 '18 at 16:36
@Augusto OK, Done. It occurs at line #117, at spinner1.setAdapter(arr);
– George Gigauri
Nov 23 '18 at 16:47
post your whole exception log too.
– Augusto
Nov 23 '18 at 16:49
@Augusto OK, Done.
– George Gigauri
Nov 23 '18 at 16:55
|
show 14 more comments
This question already has an answer here:
findViewById() returns null when I call it in onCreate()
3 answers
What is a NullPointerException, and how do I fix it?
12 answers
I'm working on android app, I used Tabbed Activity then added Spinner which contains String Array, but I think there's some issues with the ArrayAdapter.
Everytime I set adapter to my spinner and debug app, it crashes and gives me exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
Here is my code:
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/relative"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.expresshub.MainActivity"
tools:showIn="@layout/activity_main">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinner"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:spinnerMode="dialog" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinner2"
android:layout_below="@+id/spinner"
android:layout_centerHorizontal="true" />
</RelativeLayout>
in MainActivity.java
public class MainActivity extends AppCompatActivity {
/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a
* {@link FragmentPagerAdapter} derivative, which will keep every
* loaded fragment in memory. If this becomes too memory intensive, it
* may be best to switch to a
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/
private SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
private ViewPager mViewPager;
public Spinner spinner1, spinner2;
public String countries = {"აირჩიეთ გამგზავნი ქვეყანა", "საქართველო", "ავსტრალია",
"ავსტრია", "ავღანეთი", "აზერბაიჯანი", "ალბანეთი", "ალჟირი", "ა.შ.შ",
"არაბთა გაერთიანებული საამიროები", "არგენტინა", "ახალი ზელანდია",
"ბანგლადეში", "ბაჰრეინი", "ბელორუსი", "ბელგია", "ბოლივია",
"ბრაზილია", "ბულგარეთი", "გერმანია", "გვადალუპა", "გრენლანდია", "დანია",
"დიდი ბრიტანეთი", "ეგვიპტე", "ეთიოპია", "ერაყი", "ესპანეთი", "ესტონეთი",
"ვენესუელა", "ვიეტნამი", "ზიმბაბვე", "თურქეთი", "თურქმენეთი", "იაპონია", "ინდოეთი",
"ინდონეზია", "ირანი", "ირლანდია", "ისლანდია", "ისრაელი", "იტალია", "კანადა",
"კატარი", "კვიპროსი", "კოლუმბია", "კორეა", "კუბა", "ლაოსი", "ლატვია", "ლიბია",
"ლიტვა", "ლუქსემბურგი", "მადაგასკარი", "მაკედონია", "მალაიზია", "მალდივი",
"მალტა", "მაროკო", "მექსიკა", "მოლდოვა", "მონაკო", "მონღოლეთი", "ნეპალი",
"ნიგერია", "ნიდერლანდი", "ნორვეგია", "ომანი", "პაკისტანი", "პანამა", "პარაგვაი",
"პერუ", "პოლონეთი", "პორტუგალია", "პუერტო-რიკო", "რუმინეთი", "რუსეთი",
"საბერძნეთი", "სალვადორი", "სამხრეთ აფრიკის რესპუბლიკა", "საუდის არაბეთი",
"საფრანგეთი", "სერბეთი", "სინგაპური", "სირია", "სლოვაკეთი", "სლოვენია", "სომხეთი",
"სუდანი", "ტაივანი", "ტაილანდი", "ტუნისი", "უზბეკეთი", "უკრაინა", "უნგრეთი",
"ფილიპინები", "ფინეთი", "ქუვეითი", "ყაზახეთი", "შვეიცარია", "შვედეთი", "ჩეხეთი",
"ჩილე", "ჩინეთი", "ხორვატია", "ჰონკონგი"};
public int lisimages = {R.drawable.dhl, R.drawable.fedex, R.drawable.ups, R.drawable.tnt, R.drawable.gpost};
public String days = {"სატრანზიტო ვადა 1-3 დღე", "1-2 დღე", "სატრანზიტო ვადა 3-5 დღე",
"სატრანზიტო ვადა 5-7 დღე", "სატრანზიტო ვადა 6-8 დღე",
"სატრანზიტო ვადა 2-4 დღე", "სატრანზიტო ვადა 10-20 დღე",
"სატრანზიტო ვადა 15-30 დღე"};
public String companies = {"DHL Global Forwarding", "FedEx Express",
"TNT Express", "UPS Express",
"საქართველოს ფოსტის EMS", "საქართველოს ფოსტა"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Views
spinner1 = (Spinner) findViewById(R.id.spinner);
spinner2 = (Spinner) findViewById(R.id.spinner2);
// Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
// My code
ArrayAdapter<String> arr = new ArrayAdapter<String>(this, R.layout.support_simple_spinner_dropdown_item, countries);
spinner1.setAdapter(arr);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
public PlaceholderFragment() {
}
/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.tab1, container, false);
return rootView;
}
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below).
return PlaceholderFragment.newInstance(position + 1);
}
@Override
public int getCount() {
// Show 3 total pages.
return 3;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "საერთაშორისო გზავნილები";
case 1:
return "ქვეყნის შიდა გზავნილები";
case 2:
return "ამანათების ჩამოტანა";
}
return null;
}
}
}
Logcat:
11-23 20:53:48.769 12434-12434/com.expresshub E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.expresshub, PID: 12434
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.expresshub/com.expresshub.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Spinner.setAdapter(android.widget.SpinnerAdapter)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$1100(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Spinner.setAdapter(android.widget.SpinnerAdapter)' on a null object reference
at com.expresshub.MainActivity.onCreate(MainActivity.java:117)
at android.app.Activity.performCreate(Activity.java)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$1100(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
java android nullpointerexception android-spinner android-tabbed-activity
This question already has an answer here:
findViewById() returns null when I call it in onCreate()
3 answers
What is a NullPointerException, and how do I fix it?
12 answers
I'm working on android app, I used Tabbed Activity then added Spinner which contains String Array, but I think there's some issues with the ArrayAdapter.
Everytime I set adapter to my spinner and debug app, it crashes and gives me exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
Here is my code:
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/relative"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.expresshub.MainActivity"
tools:showIn="@layout/activity_main">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinner"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:spinnerMode="dialog" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinner2"
android:layout_below="@+id/spinner"
android:layout_centerHorizontal="true" />
</RelativeLayout>
in MainActivity.java
public class MainActivity extends AppCompatActivity {
/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a
* {@link FragmentPagerAdapter} derivative, which will keep every
* loaded fragment in memory. If this becomes too memory intensive, it
* may be best to switch to a
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/
private SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
private ViewPager mViewPager;
public Spinner spinner1, spinner2;
public String countries = {"აირჩიეთ გამგზავნი ქვეყანა", "საქართველო", "ავსტრალია",
"ავსტრია", "ავღანეთი", "აზერბაიჯანი", "ალბანეთი", "ალჟირი", "ა.შ.შ",
"არაბთა გაერთიანებული საამიროები", "არგენტინა", "ახალი ზელანდია",
"ბანგლადეში", "ბაჰრეინი", "ბელორუსი", "ბელგია", "ბოლივია",
"ბრაზილია", "ბულგარეთი", "გერმანია", "გვადალუპა", "გრენლანდია", "დანია",
"დიდი ბრიტანეთი", "ეგვიპტე", "ეთიოპია", "ერაყი", "ესპანეთი", "ესტონეთი",
"ვენესუელა", "ვიეტნამი", "ზიმბაბვე", "თურქეთი", "თურქმენეთი", "იაპონია", "ინდოეთი",
"ინდონეზია", "ირანი", "ირლანდია", "ისლანდია", "ისრაელი", "იტალია", "კანადა",
"კატარი", "კვიპროსი", "კოლუმბია", "კორეა", "კუბა", "ლაოსი", "ლატვია", "ლიბია",
"ლიტვა", "ლუქსემბურგი", "მადაგასკარი", "მაკედონია", "მალაიზია", "მალდივი",
"მალტა", "მაროკო", "მექსიკა", "მოლდოვა", "მონაკო", "მონღოლეთი", "ნეპალი",
"ნიგერია", "ნიდერლანდი", "ნორვეგია", "ომანი", "პაკისტანი", "პანამა", "პარაგვაი",
"პერუ", "პოლონეთი", "პორტუგალია", "პუერტო-რიკო", "რუმინეთი", "რუსეთი",
"საბერძნეთი", "სალვადორი", "სამხრეთ აფრიკის რესპუბლიკა", "საუდის არაბეთი",
"საფრანგეთი", "სერბეთი", "სინგაპური", "სირია", "სლოვაკეთი", "სლოვენია", "სომხეთი",
"სუდანი", "ტაივანი", "ტაილანდი", "ტუნისი", "უზბეკეთი", "უკრაინა", "უნგრეთი",
"ფილიპინები", "ფინეთი", "ქუვეითი", "ყაზახეთი", "შვეიცარია", "შვედეთი", "ჩეხეთი",
"ჩილე", "ჩინეთი", "ხორვატია", "ჰონკონგი"};
public int lisimages = {R.drawable.dhl, R.drawable.fedex, R.drawable.ups, R.drawable.tnt, R.drawable.gpost};
public String days = {"სატრანზიტო ვადა 1-3 დღე", "1-2 დღე", "სატრანზიტო ვადა 3-5 დღე",
"სატრანზიტო ვადა 5-7 დღე", "სატრანზიტო ვადა 6-8 დღე",
"სატრანზიტო ვადა 2-4 დღე", "სატრანზიტო ვადა 10-20 დღე",
"სატრანზიტო ვადა 15-30 დღე"};
public String companies = {"DHL Global Forwarding", "FedEx Express",
"TNT Express", "UPS Express",
"საქართველოს ფოსტის EMS", "საქართველოს ფოსტა"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Views
spinner1 = (Spinner) findViewById(R.id.spinner);
spinner2 = (Spinner) findViewById(R.id.spinner2);
// Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
// My code
ArrayAdapter<String> arr = new ArrayAdapter<String>(this, R.layout.support_simple_spinner_dropdown_item, countries);
spinner1.setAdapter(arr);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
public PlaceholderFragment() {
}
/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.tab1, container, false);
return rootView;
}
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below).
return PlaceholderFragment.newInstance(position + 1);
}
@Override
public int getCount() {
// Show 3 total pages.
return 3;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "საერთაშორისო გზავნილები";
case 1:
return "ქვეყნის შიდა გზავნილები";
case 2:
return "ამანათების ჩამოტანა";
}
return null;
}
}
}
Logcat:
11-23 20:53:48.769 12434-12434/com.expresshub E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.expresshub, PID: 12434
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.expresshub/com.expresshub.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Spinner.setAdapter(android.widget.SpinnerAdapter)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$1100(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Spinner.setAdapter(android.widget.SpinnerAdapter)' on a null object reference
at com.expresshub.MainActivity.onCreate(MainActivity.java:117)
at android.app.Activity.performCreate(Activity.java)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$1100(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
This question already has an answer here:
findViewById() returns null when I call it in onCreate()
3 answers
What is a NullPointerException, and how do I fix it?
12 answers
java android nullpointerexception android-spinner android-tabbed-activity
java android nullpointerexception android-spinner android-tabbed-activity
edited Nov 23 '18 at 18:21
Fantômas
32.4k156388
32.4k156388
asked Nov 23 '18 at 16:16
George GigauriGeorge Gigauri
66
66
marked as duplicate by Mike M.
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 17:22
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Mike M.
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 17:22
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Please edit your question to add the complete stack trace, and the parts of your code that it references.
– Mike M.
Nov 23 '18 at 16:19
which line exception occurs? And post all code please.
– Augusto
Nov 23 '18 at 16:36
@Augusto OK, Done. It occurs at line #117, at spinner1.setAdapter(arr);
– George Gigauri
Nov 23 '18 at 16:47
post your whole exception log too.
– Augusto
Nov 23 '18 at 16:49
@Augusto OK, Done.
– George Gigauri
Nov 23 '18 at 16:55
|
show 14 more comments
Please edit your question to add the complete stack trace, and the parts of your code that it references.
– Mike M.
Nov 23 '18 at 16:19
which line exception occurs? And post all code please.
– Augusto
Nov 23 '18 at 16:36
@Augusto OK, Done. It occurs at line #117, at spinner1.setAdapter(arr);
– George Gigauri
Nov 23 '18 at 16:47
post your whole exception log too.
– Augusto
Nov 23 '18 at 16:49
@Augusto OK, Done.
– George Gigauri
Nov 23 '18 at 16:55
Please edit your question to add the complete stack trace, and the parts of your code that it references.
– Mike M.
Nov 23 '18 at 16:19
Please edit your question to add the complete stack trace, and the parts of your code that it references.
– Mike M.
Nov 23 '18 at 16:19
which line exception occurs? And post all code please.
– Augusto
Nov 23 '18 at 16:36
which line exception occurs? And post all code please.
– Augusto
Nov 23 '18 at 16:36
@Augusto OK, Done. It occurs at line #117, at spinner1.setAdapter(arr);
– George Gigauri
Nov 23 '18 at 16:47
@Augusto OK, Done. It occurs at line #117, at spinner1.setAdapter(arr);
– George Gigauri
Nov 23 '18 at 16:47
post your whole exception log too.
– Augusto
Nov 23 '18 at 16:49
post your whole exception log too.
– Augusto
Nov 23 '18 at 16:49
@Augusto OK, Done.
– George Gigauri
Nov 23 '18 at 16:55
@Augusto OK, Done.
– George Gigauri
Nov 23 '18 at 16:55
|
show 14 more comments
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Please edit your question to add the complete stack trace, and the parts of your code that it references.
– Mike M.
Nov 23 '18 at 16:19
which line exception occurs? And post all code please.
– Augusto
Nov 23 '18 at 16:36
@Augusto OK, Done. It occurs at line #117, at spinner1.setAdapter(arr);
– George Gigauri
Nov 23 '18 at 16:47
post your whole exception log too.
– Augusto
Nov 23 '18 at 16:49
@Augusto OK, Done.
– George Gigauri
Nov 23 '18 at 16:55