android


change value from one spinner2 depending on spinner1 android


I have 2 custom adapters for 2 spinners with default start values.
I want to change the array on spinner2 from starting data2 to data3 etc.. depending on value of spinner1.
public class SpinerKlasa extends Activity {
String[] data1 = { "V", "A", "K", "M", "T","R", "X", "C" };
String[] data2 = { " 750", "900", "1100","1300", "1500", "1700","1950", "2250", "2700"};
String[] data3 = { " 63", "73", "103","143", "163", "203","233", "253", "293"};
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Spinner spinner1 = (Spinner) findViewById(R.id.spinner1);
spinner1.setAdapter(new MyAdapter(this, R.layout.spinner_rows, data1));
Spinner spinner2 = (Spinner) findViewById(R.id.spinner2);
spinner2.setAdapter(new MyAdapter2(this, R.layout.spinner_rows, data2));
spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int pos,
long arg3) {
if (pos == 1) {
//Here to change the array for spinner2 from data2 to data3
}
}
});
}
}
My adapters are inside the SpinerKlasa.
Here is the kode:
public class MyAdapter extends ArrayAdapter<String> {
public MyAdapter(Context context, int textViewResourceId,
String[] objects) {
super(context, textViewResourceId, objects);
}
#Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
return getCustomView(position, convertView, parent);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
return getCustomView(position, convertView, parent);
}
public View getCustomView(int position, View convertView,
ViewGroup parent) {
LayoutInflater inflater = getLayoutInflater();
View row = inflater.inflate(R.layout.spinner_rows, parent, false);
TextView label = (TextView) row.findViewById(R.id.textView1);
label.setText(data1[position]);
ImageView icon = (ImageView) row.findViewById(R.id.imageView1);
icon.setImageResource(images[position]);
return row;
}
}
//here I have the **MyAdapter2** class for spinner2 almost the same as MyAdapter class

Related Links

android:autoLink for phone numbers doesn't always work
How to filter dumped logcat file?
Change Gridview right side sider in Android
Failed to resolve: com.google.firebase:firebase-messaging:10.0.0
Why isn't setmylocationEnabled showing location button?
Can I combine these two apps (native and hybrid) into one app?
GetActivity from IntentService in Android
Android: how to align listView to bottom of custom actionBar?
Position Android popup menu to html element in web view
If mplayer lose internet connection while playing online stream, how to continue playing seamlessly when internet is back on
ActionBar menu icon disappears on orientation change
Can I connect an Android phone via USB cable to a Windows desktop to send/receive text messages?
unable to run xamarin in vs2017
HOw to show Video In YouTube using YTPlayer?
Store Google Location Place in SQLite
Service to check battery percent Android [duplicate]

Categories

HOME
redux-form
camera
mstest
apiblueprint
requirements
knitr
owl-carousel
grafana
javacc
edge
visual-studio-emulator
limit
x264
crystal-reports-2013
banner
character
windows-ce
project-intu
mxgraph
php-5.6
selenium-ide
docx
red5
foreign-keys
nim
gmm
charles
react-toolbox
object-storage
fable-f#
motion-detection
android-maps
8051
genexus-sd
paperjs
subclass
user-defined-functions
gp
realm-mobile-platform
custom-controls
aws-codecommit
hibernate-validator
laravel-eloquent
hard-drive
hibernate-search
html-encode
roblox
filesystemwatcher
typesafe-config
c9.io
kill
comparison-operators
stringtokenizer
dbnull
signal-strength
textsum
robomongo
datamaps
insight
page-replacement
magic-draw
qtranslate
excel-dna
oozie-coordinator
gameplay-kit
rocks
visual-studio-2008-sp1
model-associations
tooleap
avspeechsynthesizer
firebase-security
udpclient
android-wake-lock
qiime
omniauth-facebook
redis-cluster
lz77
invoke-sqlcmd
asyncdisplaykit
jbase
maybe
rubaxa-sortable
dock
eoferror
keyup
ms-access-2000
matlab-deployment
entity-framework-4.3
theos
filesplitting
ghcjs
crowd
cancellation
ray
conditionaltagsupport
getopt
mvc-editor-templates
route-provider
kaleidoscope
facebook-timeline
server-administration
mysql-error-2013
wcf-configuration
cuda-gdb
virtualpathprovider
google-floodlight
updatesourcetrigger
tabpanel
spread
build-environment
software-lifecycle
fdf
httpcookie
change-management

Resources

Encrypt Message