In general, I wrote a program and when checking the emulator - it works. There are two Activities in it, with buttons. But when I turned the program into apk and launched it on the phone, it starts, but in the first Activity, the buttons work, and in the second Activity nothing reacts to the touch (neither the button nor the ScrollView.) what's up

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_phone_book); scrLay = (LinearLayout) findViewById(R.id.scrollLayout); btn1 = (Button) findViewById(R.id.button1); btn3 = (Button) findViewById(R.id.button4); btn4 = (Button) findViewById(R.id.button2); btn5 = (Button) findViewById(R.id.button0); id = 1; dial = new Dialog(this); btn4.setAlpha(0); btn4.setClickable(false); dial.setContentView(R.layout.dialog); btn2 = (Button) dial.findViewById(R.id.button5); et1 = (EditText) dial.findViewById(R.id.editText); et2 = (EditText) dial.findViewById(R.id.editText2); btn2.setOnClickListener(this); btn1.setOnClickListener(this); btn3.setOnClickListener(this); btn4.setOnClickListener(this); btn5.setOnClickListener(this); ... public void onClick(View v) { switch (v.getId()) { case R.id.button0: Intent intent = new Intent(this,MainActivity.class); startActivity(intent); finish(); break; case R.id.button1: dial.show(); break; case R.id.button5: name = (et1.getText().toString()); number = (et2.getText().toString()); dial.hide(); LinearLayout.LayoutParams lParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); lParams.topMargin = 20; lParams.leftMargin = 50; lParams.rightMargin = 50; LinearLayout llblank = new LinearLayout(this); llblank.setOrientation(LinearLayout.VERTICAL); LinearLayout llblank1 = new LinearLayout(this); llblank1.setOrientation(LinearLayout.HORIZONTAL); llblank1.setBackgroundResource(R.drawable.rectangle); TextView tv1 = new TextView(this); tv1.setText(name); TextView tv2 = new TextView(this); tv2.setText(number); llblank.addView(tv1,lParams); LinearLayout.LayoutParams lParams1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); lParams1.leftMargin = 50; lParams1.rightMargin = 50; lParams1.bottomMargin = 30; lParams1.topMargin = 30; llblank.addView(tv2,lParams); cb1 = new CheckBox(this); cb1.setAlpha(0); cb1.setId(id*10); LinearLayout.LayoutParams lParams2 = new LinearLayout.LayoutParams(850, ViewGroup.LayoutParams.WRAP_CONTENT); lParams2.bottomMargin = 30; llblank1.addView(llblank,lParams2); LinearLayout.LayoutParams lParams3 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lParams3.topMargin = 39; llblank1.addView(cb1,lParams3); llblank1.setId(id); scrLay.addView(llblank1,lParams1); id = id + 1; break; case R.id.button4: i = 1; while (i<id) { CheckBox cbp = (CheckBox) findViewById(i*10); cbp.setAlpha(1); i++; } btn3.setAlpha(0); btn3.setClickable(false); btn1.setAlpha(0); btn1.setClickable(false); btn4.setAlpha(1); btn4.setClickable(true); break; case R.id.button2: i = 1; while (i<id) { CheckBox cbp = (CheckBox) findViewById(i*10); if (cbp.isChecked()) { LinearLayout lm = (LinearLayout) findViewById(i*1); lm.setVisibility(View.GONE); } i++; } i = 1; while (i<id) { CheckBox cbp = (CheckBox) findViewById(i*10); cbp.setAlpha(0); i++; } btn3.setAlpha(1); btn3.setClickable(true); btn1.setAlpha(1); btn1.setClickable(true); btn4.setAlpha(0); btn4.setClickable(false); break; } } 
  • 2
    How to ask questions here to get a helpful answer. - pavlofff
  • 2
    add your code - Aliaksandr Pitkevich

0