2011-01-24 4 views
0

2つのOnLongClickボタンを実装しようとするとエラーが発生します。 Eclipseでは、「実装されていないメソッドを追加する」ように伝えています。私は非常に開発して新しく、私はいくつかの助けを求めています。 :D私はここで間違っていますか?このコミュニティは私が前に私を助けてくれました。そして、私が私が返すことができる場所に行くとすぐに私はそれを返すことができます。私はそれのためにすべてあなたに感謝します。ここで私が取り組んでいる単純なアプリケーションのための私のコードです。EclipseとAndroidのアクティビティでエラーが発生しているように見えない

package com.kc.eas; 

import android.app.Activity; 
import android.content.Context; 
import android.content.Intent; 
import android.net.wifi.WifiManager; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.view.View.OnLongClickListener; 
import android.widget.ImageButton; 
import android.widget.RemoteViews.ActionException; 
import android.widget.Toast; 
import android.bluetooth.BluetoothAdapter; 
import android.bluetooth.BluetoothClass; 

import com.admob.android.ads.AdManager; 
import com.admob.android.ads.AdView; 

public class act2 extends Activity implements OnClickListener, OnLongClickListener { 

     /** Called when the activity is first created. */ 
     @Override 
     public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     AdManager.setTestDevices(new String[] { 
       AdManager.TEST_EMULATOR, 
       "HT089HL01612", 
     }); 

     AdView adView = (AdView)findViewById(R.id.ad); 
     adView.requestFreshAd(); 



     ImageButton batteryhistory = (ImageButton) findViewById(R.id.battery_history); 
      manageservices.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 
      Intent batteryhistoryintent = new Intent(); 
      batteryhistoryintent.setAction(Intent.ACTION_MAIN); 
      batteryhistoryintent.setClassName("com.android.settings","com.android.settings.battery_history.BatteryHistory"); 
      startActivity(batteryhistoryintent); 

     ImageButton batteryusage = (ImageButton) findViewById(R.id.battery_usage); 
      manageservices.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 
      Intent batteryusageintent = new Intent(); 
      batteryusageintent.setAction(Intent.ACTION_MAIN); 
      batteryusageintent.setClassName("com.android.settings","com.android.settings.fuelgauge.PowerUsageSummary"); 
      startActivity(batteryusageintent); 

     ImageButton batteryinfo = (ImageButton) findViewById(R.id.battery_info); 
      batteryinfo.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 
      Intent batteryinfointent = new Intent(); 
      batteryinfointent.setAction(Intent.ACTION_MAIN); 
      batteryinfointent.setClassName("com.android.settings","com.android.settings.BatteryInfo"); 
      startActivity(batteryinfointent); 

     ImageButton manageapps = (ImageButton) findViewById(R.id.manage_apps); 
      manageapps.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 
      Intent manageappsintent = new Intent(); 
      manageappsintent.setAction(Intent.ACTION_MAIN); 
      manageappsintent.setClassName("com.android.settings","com.android.settings.ManageApplications"); 
      startActivity(manageappsintent); 

     ImageButton manageservices = (ImageButton) findViewById(R.id.manage_services); 
      manageservices.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 
      Intent manageservicesintent = new Intent(); 
      manageservicesintent.setAction(Intent.ACTION_MAIN); 
      manageservicesintent.setClassName("com.android.settings","com.android.settings.RunningServices"); 
      startActivity(manageservicesintent); 

     ImageButton radioinfo = (ImageButton) findViewById(R.id.radio_info); 
      radioinfo.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 
      Intent radioinfointent = new Intent(); 
      radioinfointent.setAction(Intent.ACTION_MAIN); 
      radioinfointent.setClassName("com.android.settings","com.android.settings.RadioInfo"); 
      startActivity(radioinfointent); 


     private WifiManager wifiManager; 



     ImageButton startwifiButton = (ImageButton) findViewById(R.id.wifi); 
      startwifiButton.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 
      WifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE); 
      if(wifiManager.isWifiEnabled()){ 
       WifiManager.setWifiEnabled(false); 
       Context context = getApplicationContext(); 
       CharSequence text = "Disabling WiFi"; 
       int duration = Toast.LENGTH_SHORT; 
       Toast toast = Toast.makeText(context, text, duration); 
       toast.show(); 

      }else{ 
       WifiManager.setWifiEnabled(true); 
       Context context = getApplicationContext(); 
       CharSequence text = "Enabling WiFi"; 
       int duration = Toast.LENGTH_SHORT; 
       Toast toast = Toast.makeText(context, text, duration); 
       toast.show(); 
      } 

     private BluetoothAdapter bluetoothAdapter; 


     ImageButton bluetoothbutton = (ImageButton) findViewById(R.id.bluetooth); 
      bluetoothbutton.setOnClickListener(new View.OnClickListener(){ 
      BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); 
      { 

      if (enabled) { 
       bluetoothAdapter.enable(); 

      } else { 
       bluetoothAdapter.disable(); 
      } 


      //OnLongClickButtons// 



     ImageButton bluetoothbutton = (ImageButton) findViewById(R.id.bluetooth); 
      bluetoothbutton.setOnLongClickListener(new View.OnLongClickListener(){ 
      public void onLongClick(View v) { 
      Intent btintent = new Intent(); 
      btintent.setAction(Intent.ACTION_MAIN); 
      btintent.setClassName("com.android.settings","com.android.settings.bluetooth.BluetoothSettings"); 
      startActivity(btintent); 

     ImageButton wifisettings = (ImageButton) findViewById(R.id.wifi); 
      wifisettings.setOnLongClickListener(new View.OnLongClickListener() { 
      public void onLongClick(View v) { 
      Intent manageservicesintent = new Intent(); 
      manageservicesintent.setAction(Intent.ACTION_MAIN); 
      manageservicesintent.setClassName("com.android.settings","com.android.settings.wifi.WifiSettings"); 
      startActivity(manageservicesintent); 
         } 
     }); 
    } 
} 

     public boolean onLongClick(View v) { 
      // TODO Auto-generated method stub 
      return false; 
     } 

     public void onClick(View v) { 
      // TODO Auto-generated method stub 

     } 

答えて

1

行くと

alt text

の下に表示のようなエラーの原因は、あなたには、いくつかの抽象化を使用しているということです、

クラス名の上に置いて、「未実装のメソッドを追加」をクリックしますクラス、実装されたクラスから実装されていないメソッドを体に与えるために必要な義務

+0

すばやくご回答いただきありがとうございます。確かめます。 – AndroidKen

+0

他のものはすべて大丈夫ですか?私はこれを学ぶためにAndroid Cookbookを使用してきましたが、実際にそれをやっているのは、読書より少し難しいです。 – AndroidKen

+0

ええ、それは大丈夫だ、あなたが私の手順を実行した場合、あなたはonLongClickとonClickがクラス本体の内部で実装されていることがわかります。クラス本体の外側から関数を削除することができます。 – Reno

関連する問題