SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. E/AndroidRuntime: FATAL EXCEPTION: main
  2. Process: com.mysite.dice, PID: 6400
  3. android.content.res.Resources$NotFoundException: Resource ID #0x7f08006c type #0x12 is not valid
  4.     at android.content.res.Resources.loadXmlResourceParser(Resources.java:2315)
  5.     at android.content.res.Resources.getLayout(Resources.java:1264)
  6.     at android.view.LayoutInflater.inflate(LayoutInflater.java:424)
  7.     at com.mysite.dice.CurrencyAdapter.getView(CurrencyAdapter.java:28)
  8.     at android.widget.AbsListView.obtainView(AbsListView.java:2491)
  9.     at android.widget.GridView.onMeasure(GridView.java:1070)
  10.     at android.view.View.measure(View.java:20084)
  11.     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6282)
  12.     at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
  13.     at android.view.View.measure(View.java:20084)
  14.     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6282)
  15.     at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
  16.     at android.view.View.measure(View.java:20084)
  17.     at com.android.internal.widget.AlertDialogLayout.tryOnMeasure(AlertDialogLayout.java:142)
  18.     at com.android.internal.widget.AlertDialogLayout.onMeasure(AlertDialogLayout.java:67)
  19.     at android.view.View.measure(View.java:20084)
  20.     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6282)
  21.     at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
  22.     at android.view.View.measure(View.java:20084)
  23.     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6282)
  24.     at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
  25.     at android.view.View.measure(View.java:20084)
  26.     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6282)
  27.     at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
  28.     at com.android.internal.policy.DecorView.onMeasure(DecorView.java:714)
  29.     at android.view.View.measure(View.java:20084)
  30.     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2640)
  31.     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1548)
  32.     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1846)
  33.     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1462)
  34.     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6965)
  35.     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:907)
  36.     at android.view.Choreographer.doCallbacks(Choreographer.java:709)
  37.     at android.view.Choreographer.doFrame(Choreographer.java:644)
  38.     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:893)
  39.     at android.os.Handler.handleCallback(Handler.java:836)
  40.     at android.os.Handler.dispatchMessage(Handler.java:103)
  41.     at android.os.Looper.loop(Looper.java:203)
  42.     at android.app.ActivityThread.main(ActivityThread.java:6251)
  43.     at java.lang.reflect.Method.invoke(Native Method)
  44.     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
  45.     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
  46.    
  47. public class DialogSelectCurrency extends DialogFragment {
  48.  
  49. @NonNull
  50. @Override
  51. public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
  52.     super.onCreateDialog(savedInstanceState);
  53.     List<Currency> currencies = getCurrencies();
  54.     CurrencyAdapter adapter = new CurrencyAdapter(getContext(), R.id.item_currency, currencies);
  55.     AdapterView.OnItemClickListener itemListener = new AdapterView.OnItemClickListener() {
  56.  
  57.         @Override
  58.         public void onItemClick(AdapterView<?> parent, View v,
  59.                                 int position, long id) {
  60.             Toast.makeText(getContext(), "Вы выбрали "
  61.                             + parent.getItemAtPosition(position).toString(),
  62.                     Toast.LENGTH_SHORT).show();
  63.         }
  64.     };
  65.     GridView v = new GridView(getContext());
  66.     v.setOnItemClickListener(itemListener);
  67.     v.setAdapter(adapter);
  68.     AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
  69.     builder.setView(v);
  70.     builder.create();
  71.     return  builder.show();
  72. }
  73.    
  74. public class CurrencyAdapter extends ArrayAdapter<Currency> {
  75. private LayoutInflater inflater;
  76. private int resource_id;
  77. private List<Currency> currencies;
  78.  
  79. public CurrencyAdapter(Context context, int resource_id, List<Currency> currencies) {
  80.     super(context, resource_id, currencies);
  81.     this.currencies = currencies;
  82.     this.resource_id = resource_id;
  83.     this.inflater = LayoutInflater.from(context);
  84. }
  85.  
  86. public View getView(int position, View convertView, ViewGroup parent) {
  87.     View view;
  88.     if (convertView == null) {
  89.         view = inflater.inflate(this.resource_id, parent, false);
  90.         TextView textView = convertView.findViewById(resource_id);
  91.         Currency cur = currencies.get(position);
  92.         Drawable currencyImg = getContext().getResources().getDrawable(cur.getImage(), null);
  93.         textView.setCompoundDrawablesWithIntrinsicBounds(null, currencyImg, null, null);
  94.         textView.setText(cur.getName());
  95.     } else {
  96.         view = convertView;
  97.     }
  98.     return view;
  99. }
  100.    
  101. <?xml version="1.0" encoding="utf-8"?>
  102. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  103. xmlns:app="http://schemas.android.com/apk/res-auto"
  104. xmlns:tools="http://schemas.android.com/tools"
  105. android:id="@+id/layout_root"
  106. android:layout_width="wrap_content"
  107. android:layout_height="wrap_content"
  108. android:background="@color/colorFon"
  109. android:orientation="vertical">
  110.  
  111. <TextView
  112.     android:id="@+id/item_currency"
  113.     android:layout_width="wrap_content"
  114.     android:layout_height="wrap_content"
  115.     android:layout_rowWeight="1"
  116.     android:layout_margin="2dp"
  117.     android:background="@drawable/bg_panel"
  118.     android:drawableTop="@drawable/ic_question_mark"
  119.     android:gravity="center"
  120.     android:paddingStart="8dp"
  121.     android:paddingTop="8dp"
  122.     android:paddingEnd="8dp"
  123.     android:text="@string/currency"
  124.     android:textColor="@color/colorText"
  125.     android:textSize="30sp"
  126.     app:layout_constraintBottom_toBottomOf="parent"
  127.     app:layout_constraintEnd_toEndOf="parent"
  128.     app:layout_constraintStart_toStartOf="parent"
  129.     app:layout_constraintTop_toTopOf="parent" />
  130.  
  131. </LinearLayout>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top