Android : How to scroll down to a specific item in scroll view and highlight the item

on Friday, October 24, 2014


Here is a activity Translation Activity. I have two images one for selected and one for not selected, I am using the below code to set the image of previous selected language as selected. All the languages are listed with a image in scroll view. i also want to scroll down to the selected language and want to highlight that item for a while just to notify the user that this is the language you have selected before. how can i achieve this goal. Thanks in advance for any help.



@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
FrameLayout framelayout = (FrameLayout) findViewById(R.id.maincontent);
LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View activityView = layoutInflater.inflate(
R.layout.activity_select_language, null, false);
framelayout.addView(activityView);
setTitle("TRANSLATION LANGUAGE");


openDB();

arabicSelect = (ImageView) findViewById(R.id.arabicSelect);
azerbaijaniSelect = (ImageView) findViewById(R.id.azerbaijaniSelect);
bosnianSelect = (ImageView) findViewById(R.id.bosnianSelect);
chineseSelect = (ImageView) findViewById(R.id.chineseSelect);
dutchSelect = (ImageView) findViewById(R.id.dutchSelect);
englishSelect = (ImageView) findViewById(R.id.englishSelect);
frenchSelect = (ImageView) findViewById(R.id.frenchSelect);
persianSelect = (ImageView) findViewById(R.id.persianSelect);
urduSelect = (ImageView) findViewById(R.id.urduSelect);
portugueseSelect = (ImageView) findViewById(R.id.portugueseSelect);
russianSelect = (ImageView) findViewById(R.id.russianSelect);
spanishSelect = (ImageView) findViewById(R.id.spanishSelect);
swedishSelect = (ImageView) findViewById(R.id.swedishSelect);

String translationLanguage = databaseHelper.getLanguageSetting();
select(translationLanguage);

}

private void select(String translationLanguage) {
// TODO Auto-generated method stub

if (translationLanguage.equalsIgnoreCase("Only Arabic")) {
arabicSelect.setImageResource(R.drawable.selected_circle);
} else if (translationLanguage.equalsIgnoreCase("az_musayev")) {
azerbaijaniSelect.setImageResource(R.drawable.selected_circle);
} else if (translationLanguage.equalsIgnoreCase("bs_korkut")) {
bosnianSelect.setImageResource(R.drawable.selected_circle);
} else if (translationLanguage.equalsIgnoreCase("zh_jian")) {
chineseSelect.setImageResource(R.drawable.selected_circle);
} else if (translationLanguage.equalsIgnoreCase("nl_sireger")) {
dutchSelect.setImageResource(R.drawable.selected_circle);
} else if (translationLanguage.equalsIgnoreCase("en_itani")) {
englishSelect.setImageResource(R.drawable.selected_circle);
} else if (translationLanguage.equalsIgnoreCase("fr_hamidullah")) {
frenchSelect.setImageResource(R.drawable.selected_circle);
} else if (translationLanguage.equalsIgnoreCase("fa_makarem")) {
persianSelect.setImageResource(R.drawable.selected_circle);
} else if (translationLanguage.equalsIgnoreCase("ur_jalandhry")) {
urduSelect.setImageResource(R.drawable.selected_circle);
} else if (translationLanguage.equalsIgnoreCase("pt_elhayek")) {
portugueseSelect.setImageResource(R.drawable.selected_circle);
} else if (translationLanguage.equalsIgnoreCase("ru_kuliev")) {
russianSelect.setImageResource(R.drawable.selected_circle);
} else if (translationLanguage.equalsIgnoreCase("et_cortes")) {
spanishSelect.setImageResource(R.drawable.selected_circle);
} else if (translationLanguage.equalsIgnoreCase("sv_Bernstrom")) {
swedishSelect.setImageResource(R.drawable.selected_circle);
}
}

0 comments:

Post a Comment