gpt4 book ai didi

android - 错误 : ViewPostImeInputStage ACTION_DOWN

转载 作者:太空宇宙 更新时间:2023-11-03 11:07:49 25 4
gpt4 key购买 nike

我不明白为什么我的按钮的 onClick 方法不起作用。每次单击按钮时,我的 logcat 都会显示 ViewPostImeInputStage Action_Down。

感谢您的帮助!

public class MainActivity extends ActionBarActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

if (savedInstanceState == null) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
BluetoothConnect fragment = new BluetoothConnect();
transaction.add(R.id.sample_content_fragment, fragment);
transaction.commit();
}

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}

这是我的 fragment 。

公共(public)类 BluetoothConnect 扩展 fragment {

//For debugging purposes
private static final String TAG = "BluetoothConnect";


// Intent request codes
private static final int REQUEST_CONNECT_DEVICE_SECURE = 1;
private static final int REQUEST_CONNECT_DEVICE_INSECURE = 2;
private static final int REQUEST_ENABLE_BT = 3;

//Main buttons
private Button shareButton;
private Button listenButton;
private TextView test;

/**
* Name of the connected device
*/
private String mConnectedDeviceName = null;

/**
* Local Bluetooth adapter
*/
private BluetoothAdapter mBluetoothAdapter = null;



@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setHasOptionsMenu(true);

//Get local Bluetooth adapter
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();



//If the adapter is null, then Bluetooth is not supported
if (mBluetoothAdapter == null) {
FragmentActivity activity = getActivity();
Toast.makeText(activity, "Bluetooth is not available", Toast.LENGTH_LONG).show();
activity.finish();
}
}

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {

return inflater.inflate(R.layout.activity_main, container, false);
}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
listenButton = (Button) view.findViewById(R.id.listen);
shareButton = (Button) view.findViewById(R.id.share);
test = (TextView) view.findViewById(R.id.test);
}


@Override
public void onStart() {
super.onStart();
//If BT is not on, request that it be enabled
if (!mBluetoothAdapter.isEnabled()) {
Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
} else {
setupButtons();

}
}


@Override
public void onDestroy() {
super.onDestroy();
//Figure out what to do if we need to destroy

}

@Override public void onResume() {
super.onResume();
//figure out what to do if person pauses out of app

}

public void setupButtons() {
Log.d(TAG, "setupButtons()");

//Initialize the music buttons

listenButton.setOnClickListener(new ButtonOnClickListener("listen"));

Log.d(TAG, "finished listenButton");

shareButton.setOnClickListener(new ButtonOnClickListener("share"));

}



private class ButtonOnClickListener implements View.OnClickListener {
String type;

public ButtonOnClickListener(String button) {
Log.d(TAG, this.type);
this.type = button;
}

public void onClick(View view) {
if (this.type == "listen") {
listenMusic();
} else {
shareMusic();
}
}
}


private void ensureDiscoverable() {
if (mBluetoothAdapter.getScanMode() !=
BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
startActivity(discoverableIntent);
}
}

private void listenMusic() {
Log.d(TAG, "OMG ITS WORKING");
}

private void shareMusic() {
Log.d(TAG, "OMG ITS WORKING");
}

非常感谢!

最佳答案

看这里 https://stackoverflow.com/a/32016362/5281187

将您的布局包裹在您已有的布局上

关于android - 错误 : ViewPostImeInputStage ACTION_DOWN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30960234/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com