Project

General

Profile

« Previous | Next » 

Revision 9513f213

Added by Leszek Koltunski over 4 years ago

Improve setting text size in Spinners.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogEffects.java
32 32
import android.view.Gravity;
33 33
import android.view.LayoutInflater;
34 34
import android.view.View;
35
import android.view.ViewGroup;
35 36
import android.view.Window;
36 37
import android.view.WindowManager;
37 38
import android.widget.AdapterView;
......
184 185
    spinner.setOnItemSelectedListener(this);
185 186
    String[] appear = BaseEffect.Type.getType(index).getNames();
186 187

  
187
    ArrayAdapter<String> adapterType = new ArrayAdapter<>(act,android.R.layout.simple_spinner_item, appear);
188
    ArrayAdapter<String> adapterType = new ArrayAdapter<String>(act, android.R.layout.simple_spinner_item, appear)
189
      {
190
      @NonNull
191
      public View getView(int position, View convertView, @NonNull ViewGroup parent)
192
        {
193
        View v = super.getView(position, convertView, parent);
194
        TextView tv = ((TextView) v);
195
        tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
196
        return v;
197
        }
198
      };
199

  
188 200
    adapterType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
189 201
    spinner.setAdapter(adapterType);
190 202
    spinner.setSelection(beType.getCurrentType());
......
276 288

  
277 289
  public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
278 290
    {
279
    ((TextView) parent.getChildAt(0)).setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
280

  
281 291
    int parentID = parent.getId();
282 292
    int len = BaseEffect.Type.LENGTH;
283 293

  
src/main/java/org/distorted/states/RubikStatePlay.java
28 28
import android.view.Gravity;
29 29
import android.view.LayoutInflater;
30 30
import android.view.View;
31
import android.view.ViewGroup;
31 32
import android.widget.AdapterView;
32 33
import android.widget.ArrayAdapter;
33 34
import android.widget.Button;
......
36 37
import android.widget.PopupWindow;
37 38
import android.widget.TextView;
38 39

  
40
import androidx.annotation.NonNull;
39 41
import androidx.appcompat.widget.AppCompatSpinner;
40 42

  
41 43
import org.distorted.dialogs.RubikDialogEffects;
......
178 180

  
179 181
    if( mLevelValue>maxLevel ) mLevelValue=1;
180 182

  
181
    mSpinnerAdapter = new ArrayAdapter<>(act,android.R.layout.simple_spinner_item, levels);
183
    mSpinnerAdapter = new ArrayAdapter<String>(act, android.R.layout.simple_spinner_item, levels)
184
      {
185
      @NonNull
186
      public View getView(int position, View convertView, @NonNull ViewGroup parent)
187
        {
188
        View v = super.getView(position, convertView, parent);
189
        TextView tv = ((TextView) v);
190
        tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButtonSize);
191
        return v;
192
        }
193
      };
194

  
182 195
    mSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
183 196
    mLevelSpinner.setAdapter(mSpinnerAdapter);
184 197
    mLevelSpinner.setSelection(mLevelValue-1);
......
428 441

  
429 442
  public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
430 443
    {
431
    ((TextView) parent.getChildAt(0)).setTextSize(TypedValue.COMPLEX_UNIT_PX, mButtonSize);
432 444
    mLevelValue = pos+1;
433 445
    }
434 446

  

Also available in: Unified diff