2013-03-26 82 views
-1
ImageView ivCamera; 

FlashLightControl = (Button)findViewById(R.id.flashcontrol); 
ivCamera = (ImageView)findViewById(R.id.iv_camera); 

Syntax error on token ";" ,, expected.語法錯誤,在行多個標記


- Multiple markers at this line 
- Syntax error on token ")", { expected after this token 
- Syntax error, insert ";" to complete  FieldDeclaration 
- Syntax error on token ".", ... expected 
- Return type for the method is missing 

Syntax error, insert "}" to complete MethodBody

+0

這是一個提問和回答的網站,所以您應該首先確定您的「問題」中存在問號。 – antonijn 2013-03-26 13:29:43

+0

缺少變量名稱。 – 2013-03-26 13:32:37

回答

0

您需要命名FlashLightControl變量:

FlashLightControl flc = (Button)findViewById(R.id.flashcontrol); 
ivCamera = (ImageView)findViewById(R.id.iv_camera); 

而在另一個說明,是Button能夠被視爲FlashLightControl實例嗎?

也許你想

Button flashLightControl = (Button)findViewById(R.id.flashcontrol); 
+0

你說得對,夥計)我想我可以先聲明變量「Button flc;」然後給它們賦值「flc =(Button)findViewById(R.id.flashcontrol);」 – 2013-03-26 13:49:02

+0

你可以*聲明變量而不初始化它,這就是你如何描述的:「Button flc;」然而,'flc'將是空的,直到你明確*初始化它與「flc =(Button)findViewById(R.id.flashcontrol);」 – ComethTheNerd 2013-03-26 14:00:41

0

看來你缺少的對象引用。請從改變下面一行代碼:

FlashLightControl = (Button)findViewById(R.id.flashcontrol); 

要這樣:

FlashLightControl flashControlName = (Button)findViewById(R.id.flashcontrol); 

如果該FlashLightControl的類型是Button的或與之兼容然而,這隻會工作。

希望這會有所幫助。

相關問題