Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
package mate.files; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.content.res.Resources; import android.graphics.Typeface; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; import android.widget.TextView; import java.util.Locale; import java.util.concurrent.TimeUnit; public class Welcome extends AppCompatActivity { //Counter for Spinner's Listener int Counter = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); getSupportActionBar().hide(); //Title Font TextView textView = (TextView) findViewById(R.id.WelcomeTitle); Typeface typeFace = Typeface.createFromAsset(getAssets(), "Title.ttf"); textView.setTypeface(typeFace); //Button Font Button button = (Button) findViewById(R.id.nextButton); button.setTypeface(typeFace); //Lang Spinner Spinner Lang = (Spinner) findViewById(R.id.Lang); ArrayAdapter<?> Adapter = ArrayAdapter.createFromResource(this, R.array.Langs, R.layout.my_spinner); Adapter.setDropDownViewResource(R.layout.my_spinner_dropdn); Lang.setAdapter(Adapter); Locale CurLang = this.getResources().getConfiguration().getLocales().get(0); Resources res = this.getResources(); android.content.res.Configuration conf = res.getConfiguration(); if (CurLang.toString().equals("en_US")) { Lang.setSelection(0); } if (CurLang.toString().equals("ru_RU")) { Lang.setSelection(1); } AdapterView.OnItemSelectedListener itemSelectedListener = new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (Counter == 0) { switch (position) { default: break; case 0: conf.setLocale(new Locale("en_US")); break; case 1: conf.setLocale(new Locale("ru_RU")); break; } getBaseContext().getResources().updateConfiguration(conf, null); try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } Intent intent = new Intent(getBaseContext(), MainActivity.class); startActivity(intent); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }; Lang.setOnItemSelectedListener(itemSelectedListener); } public void GetStartedClicked(View view) { Intent intent = new Intent(this, WelcomeAccount.class); startActivity(intent); } public void LangClicked(View view) { Counter = 1; } }