在创建我的应用程序时,我遇到了一个问题,在更改为第二个活动后,我似乎无法更改为第三个。我已经尝试将函数一直修改为简单的活动调用;但是我仍然遇到问题,我可以点击模拟器中的按钮,但没有任何反应。想法?
爪哇:
$('#test').on("click",function(e){
window.open("getEmployeeInstructions.php", 'download1');
window.open("getMergedEmployeeReports.php", 'download2');
window.open("getQualityHandbook.php", 'download3');
window.open("getEquipmentReport.php", 'download4');
return false;
});
XML:
public class NewGameActivity extends AppCompatActivity {
public Spinner players, bestOf;
public Button startButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_game);
players = (Spinner) findViewById(R.id.players);
Integer[] items1 = new Integer[]{2,3,4,5,6,7,8,9,10};
ArrayAdapter<Integer> adapter1 = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, items1);
players.setAdapter(adapter1);
bestOf = (Spinner) findViewById(R.id.bestOf);
Integer[] items2 = new Integer[]{1,3,5,7,9,11,13,15,17,19,21,23,25};
ArrayAdapter<Integer> adapter2 = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, items2);
bestOf.setAdapter(adapter2);
startButton =(Button)findViewById(R.id.startButton);
startButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_new_game, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void sendMessageStart(View view) {
int playerNum = Integer.valueOf(players.getSelectedItem().toString());
int games = Integer.valueOf(bestOf.getSelectedItem().toString());
RadioGroup group;
group = (RadioGroup) findViewById(R.id.group);
int selectedId = group.getCheckedRadioButtonId();
Bundle bundle = new Bundle();
bundle.putInt("players", playerNum);
bundle.putInt("games", games);
if (selectedId == 0) {
Intent intent = new Intent(this, ThreeSignGameActivity.class);
intent.putExtras(bundle);
startActivity(intent);
}
else {
Intent intent = new Intent(this, FiveSignGameActivity.class);
intent.putExtras(bundle);
startActivity(intent);
}
}
}
答案 0 :(得分:2)
XML包含android:onClick="sendMessageStart"
,您已在其方法sendMessageStart
中实现了逻辑,并且您还获得了Button
对象并为Button
设置了一个侦听器。 />
startButton =(Button)findViewById(R.id.startButton);
尝试删除此代码
startButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});