📜  android get id of view - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:33.844000             🧑  作者: Mango

代码示例2
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.add_04:
        Toast.makeText(MainActivity.this, "1", Toast.LENGTH_LONG).show();
        break;
    case R.id.add_05:
        Toast.makeText(MainActivity.this, "2", Toast.LENGTH_LONG).show();
        break;
    }
}