Ошибки в активности Eclipse и Android, похоже, не могут этого понять.JAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Ошибки в активности Eclipse и Android, похоже, не могут этого понять.

Сообщение Anonymous »

Я постоянно получаю ошибки при попытке реализовать пару кнопок OnLongClick. Eclipse постоянно говорит мне «добавить нереализованные методы». Я новичок в разработке и прошу помощи. :D Что я здесь делаю не так? Это сообщество помогло мне раньше, и как только я доберусь до места, где смогу отдать должное, я сделаю это. Я благодарю вас всех за это. Вот мой код простого приложения, над которым я работаю.

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

}


Подробнее здесь: https://stackoverflow.com/questions/477 ... -figure-it
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»