0
按鈕的父ID在我的應用程序哈瓦一個的LinearLayout和其子鍵。觸摸按鈕後,我需要知道id的linearlayout。這裏是我的代碼找出機器人
private final class MyTouchListener implements OnTouchListener
{
public boolean onTouch(View view, MotionEvent motionEvent)
{
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN)
{
View v = ((View)view.getParent());
int id = v.getId();
Toast.makeText(getApplicationContext(), id, Toast.LENGTH_SHORT).show();
我得到android.content.res.Resources $ NotFoundException。我怎樣才能得到linearlayout的id。謝謝....
是的,那是我的錯[email protected] Sood – andDev 2013-02-26 11:22:03
現在我需要與ID一起工作,但不能得到ID的整數值@Raghav Sood – andDev 2013-02-26 12:34:20
呃,如果你要烘烤它,那麼你已經有了整數值。只需使用存儲在'id'當你需要它的價值 – 2013-02-26 12:36:18