如何在Eclipse中为Java匿名方法设置代码格式化程序

pap*_*tis 6 java eclipse coding-style

我正在使用Eclipse进行Android开发,我已经设置了我的代码格式化样式,但仍然有匿名方法,我无法弄清楚如何在Eclipse中进行格式化.这就是Eclipse现在如何格式化匿名方法:

// The BroadcastReceiver that listens for discovered devices and
    // changes the title when discovery is finished
    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
                                                  @Override
                                                  public void onReceive(Context context, Intent intent) {
                                                      String action = intent.getAction();
                                                      Utils.Log.i("BLUETOOTH: " + action);
                                                      if (BluetoothDevice.ACTION_FOUND.equals(action)) {
                                                          // Get the
                                                          // BluetoothDevice
                                                          // object from the
                                                          // Intent
                                                          BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                                                          // If it's already
                                                          // paired, skip it,
                                                          // because it's been
                                                          // listed already
                                                          if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
                                                              if (mNewDevicesArrayAdapter.getCount() == 0) {
                                                                  mNewDevicesArrayAdapter.add(device);
                                                              }
                                                              btDevicesUpdateList.add(device);
                                                          }
                                                      }
                                                      else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
                                                          mNewDevicesArrayAdapter.setItems(btDevicesUpdateList);
                                                          mNewDevicesArrayAdapter.notifyDataSetChanged();
                                                          btDevicesUpdateList.clear();
                                                          mBtAdapter.startDiscovery();
                                                      }
                                                      else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
                                                          if (mBtAdapter.getState() == BluetoothAdapter.STATE_ON) {
                                                              switchToView(viewBluetoothOn);
                                                              firstTimeDiscover();
                                                          }
                                                          else if (mBtAdapter.getState() == BluetoothAdapter.STATE_OFF) {
                                                              switchToView(viewBluetoothOff);
                                                          }
                                                      }
                                                  }
                                              };
Run Code Online (Sandbox Code Playgroud)

看到?它非常糟糕.格式化匿名方法声明以保持在左侧并且不在=相同字符下的正确设置是什么?

Eug*_*hov 0

您似乎有某种自定义格式化程序设置。转到项目属性/Java 代码样式/格式化程序/启用项目特定设置,然后选择“Java 约定”内置格式化程序配置文件。