07-11 20:44:43.348 12614-12614/com.karanvir.search E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.karanvir.search, PID: 12614
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:355)
at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:324)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:285)
at android.support.v7.app.AppCompatDialog.setContentView(AppCompatDialog.java:83)
at android.support.v7.app.AlertController.installContent(AlertController.java:225)
at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:257)
at android.app.Dialog.dispatchOnCreate(Dialog.java:578)
at android.app.Dialog.show(Dialog.java:314)
at android.support.v7.app.AlertDialog$Builder.show(AlertDialog.java:955)
at com.karanvir.search.MainActivity.onOptionsItemSelected(MainActivity.java:143)
at android.app.Activity.onMenuItemSelected(Activity.java:3204)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:408)
at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:195)
at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:113)
at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:113)
at android.support.v7.app.ToolbarActionBar$2.onMenuItemClick(ToolbarActionBar.java:69)
at android.support.v7.widget.Toolbar$1.onMenuItemClick(Toolbar.java:206)
at android.support.v7.widget.ActionMenuView$MenuBuilderCallback.onMenuItemSelected(ActionMenuView.java:776)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:156)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:969)
at android.support.v7.view.menu.MenuPopup.onItemClick(MenuPopup.java:127)
at android.widget.AdapterView.performItemClick(AdapterView.java:345)
at android.widget.AbsListView.performItemClick(AbsListView.java:1547)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3821)
at android.widget.AbsListView$3.run(AbsListView.java:5841)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
--------- beginning of system
07-11 20:44:43.388 752-13505/? E/android.os.Debug: ro.product_ship = true
07-11 20:44:43.388 752-13505/? E/android.os.Debug: ro.debug_level = 0x4f4c
07-11 20:44:43.388 752-13505/? E/android.os.Debug: sys.mobilecare.preload = false
07-11 20:44:43.428 13515-13515/? E/Zygote: v2
07-11 20:44:43.428 13515-13515/? E/Zygote: accessInfo : 0
07-11 20:44:49.228 28799-28830/? E/ContactsProvider_EventLog: Flush buffer to file cnt : 10 size : 7Kb duration : 153ms lastUpdatedAfter : 19910 ms mFlush_time_threasold : 2000 mCurrentSize : 3670
当我在我的设置中点击它的选项时,我的新警告对话框不会显示,而是我的应用程序完全崩溃了。我在这里做什么很困惑,有人可以帮助我。我也很擅长开发,如果这是一个不起眼的问题,那就很抱歉。感谢您阅读
ANDROID STUDIO
package com.karanvir.search;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.view.inputmethod.InputMethodManager;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Random;
public class MainActivity extends AppCompatActivity {
Random rn;
AutoCompleteTextView searchBar;
public static String urlGlobal;
TextView con;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
searchBar=(AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);
Button button=(Button) findViewById(R.id.button);
con=(TextView) findViewById(R.id.textView);
rn= new Random();
final SharedPreferences perf= this.getSharedPreferences("com.karanvir.shareprefernces", Context.MODE_PRIVATE);
//setting up an alert
if(perf==null){
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.alert_dark_frame)
.setTitle("How to use")
.setMessage("Search what you want in the search bar! after we will choose a search engine our computer will recommend. After that you can change the search engine using the options menu in the right hand corner")
//then need to set a onclick listener with our positive button
.setPositiveButton("eng", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, "its done", Toast.LENGTH_SHORT).show();
//where we would right our code where the user would confirm us to do
perf.edit().putString("choiceOne","eng").apply();
}
//25165012725
})
.setNegativeButton("fren", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
perf.edit().putString("choiceOne","fre").apply();
}
})
.show();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.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();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings4) {
Intent intentGoogle= new Intent(getApplicationContext(),Main2Activity.class);
startActivity(intentGoogle);
return true;
} else if(id ==R.id.action_settings2){
Intent intentGoogle= new Intent(getApplicationContext(),Yahoo.class);
startActivity(intentGoogle);
return true;
}else if (id==R.id.action_settings3){
Intent intentGoogle= new Intent(getApplicationContext(),MainActivity.class);
startActivity(intentGoogle);
return true;
}else if(id==R.id.action_settings1){
new AlertDialog.Builder(getApplicationContext())
.setIcon(android.R.drawable.ic_dialog_info)
.setTitle("About")
.setMessage(".....")
.show();
return true;
}
else if (id==R.id.action_settings5){
new AlertDialog.Builder(getApplicationContext())
.setIcon(android.R.drawable.ic_dialog_info)
.setTitle("About")
.setMessage("This app intercha")
.show();
return true;
}
return super.onOptionsItemSelected(item);
}
public void jump(View view){
//intnet changing target of our code
urlGlobal=searchBar.getText().toString();
Log.i("stuff",urlGlobal);
int pageJump = rn.nextInt(3)+1;
if (pageJump==1){
//google
Intent intentGoogle= new Intent(getApplicationContext(),Main2Activity.class);
startActivity(intentGoogle);
} else if (pageJump==2){
//YAHOO
Intent intentGoogle= new Intent(getApplicationContext(),Yahoo.class);
startActivity(intentGoogle);
} else if(pageJump==3){
//GOOGLE
Intent intentGoogle= new Intent(getApplicationContext(),Main2Activity.class);
startActivity(intentGoogle);
}
try {
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
} catch (Exception e) {
// TODO: handle exception
}
}
}
答案 0 :(得分:0)
当你调用AlertDialog.Builder()时,你也应该调用.create() 然后调用方法dialog.show()
答案 1 :(得分:0)
代码就像这样
enctype=multipart/form-data
答案 2 :(得分:0)
把这段代码
library(jsonlite)
library(RCurl)
library(digest)
apikey = "2...XXX...3" #insert your key
apisecret = "7...XXX...c" #insert your secret
nonce=as.numeric(as.POSIXct(Sys.time()));
uri = paste0('https://bittrex.com/api/v1.1/market/getopenorders?apikey=',apikey,'&nonce=',nonce)
sign = hmac(apisecret,uri,'sha512')
ch = getCurlHandle()
curlSetOpt(.opts=list(httpheader=c(apisign=sign)), .forceHeaderNames = TRUE, curl=ch)
ans = getURL(uri,curl=ch)
response = fromJSON(ans)
response$result #contains the table of orders
答案 3 :(得分:0)
在styles.xml中,将您的样式更改为
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">