Note that there are some explanatory texts on larger screens.

plurals
  1. POCkeckBox has map returning Null
    primarykey
    data
    text
    <p>This is my code, the Spawn method gets called when a button is pressed:</p> <pre><code> public void Spawn (View V) { LayoutInflater inflater = (LayoutInflater)this.getSystemService( Context.LAYOUT_INFLATER_SERVICE ); View iv = inflater.inflate( R.layout.motor_block, null ); //LinearLayout iv = (LinearLayout) findViewById(R.id.motor_block); RelativeLayout rl = (RelativeLayout) findViewById(R.id.layout); CheckBox A = (CheckBox)findViewById(R.id.checkBox1); boxesA.put(currentKey,A); CheckBox B = (CheckBox)findViewById(R.id.checkBox2); boxesB.put(currentKey,B); CheckBox C = (CheckBox)findViewById(R.id.checkBox3); boxesC.put(currentKey,C); iv.setTag(currentKey); rl.addView(iv); currentKey ++; iv.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v,MotionEvent event) { iAction = event.getActionMasked(); switch (iAction) { case MotionEvent.ACTION_MOVE: v.getLocationOnScreen(aLocation); // get absolute physical location of this View iOffsetX = (aLocation [ 0 ] - (int) v.getX()); // subtract out this View's relative location within its parent View... iOffsetY = (aLocation [ 1 ] - (int) v.getY()); // ...yielding the offsets that convert getRawX/Y's coords to setX/Y's coords iNewX = (int) event.getRawX(); // get absolute physical coords of this touch iNewY = (int) event.getRawY(); iNewX -= iOffsetX; // remove parent View's screen offset (calc'd above) iNewY -= iOffsetY; iNewX -= iRelX; // remove stored touch offset iNewY -= iRelY; v.setX(iNewX); // finally, move View to new coords (relative to its parent View) v.setY(iNewY); bExitValue = true; break; case MotionEvent.ACTION_DOWN: if (delete){ v.setVisibility(View.GONE); } iRelX = (int) event.getX(); // preserve offset of this touch within the View iRelY = (int) event.getY(); bExitValue = false; break; case MotionEvent.ACTION_UP: bExitValue = true; break; } return (bExitValue); } }); iv.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { v.setHapticFeedbackEnabled(false); if (!bExitValue) { Log.i("TAG",(String) v.getTag()); int key = (Integer) v.getTag(); CheckBox A = boxesA.get(key); CheckBox B = boxesB.get(key); CheckBox C = boxesC.get(key); if (A.isChecked()){ //A IS NULL Log.i("Checked","A"); } if (B.isChecked()){ Log.i("Checked","B"); } if (C.isChecked()){ Log.i("Checked","C"); } Log.i("Click","LONG"); v.setHapticFeedbackEnabled(true); } return true; } }); } </code></pre> <p>In this method, a View is spawned which has three check-boxes in it. I just put them in a Hash-map with an Integer as a key. It turns out that A is null, which makes no sense to me. Any ideas?</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload