- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
当我需要将一些数据从一个 Activity
传输到另一个时,我的代码出现了一些问题。第一个 Activity
(ViewCashflow
),我想将一些数据从 ViewCashflow
传输到第二个 Activity
(NewTransaction
)。这里它运行良好,没有错误,数据传输成功。但是,我不知道当我直接运行第二个 Activity
时发生了什么(而不是像以前传输数据时那样从第一个 Activity
运行)我得到了空指针异常我用来从第一个 Activity
接收数据的方法。
我试图弄清楚那里的所有事情,但仍未解决。在其他 Activity
(ViewCategory
和 AddCategory
)中,我正在做同样的事情(将数据从 ViewCategory
传输到 AddCategory
) 它运行良好,当我直接运行 AddCategory
时没有错误,但代码与我得到的两个 Activity
完全具有相同的模式错误。
请高手帮帮我。先谢谢了。
错误报告给我这个:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.os.Bundle.getBoolean(java.lang.String)' on a null object reference at com.example.ever_ncn.cashflow.NewTransaction.onCreate(NewTransaction.java:68)
注意。这是我的第一个 Activity
(ViewCashflow
)
public class ViewCashflow extends ActionBarActivity {
private SQLiteDatabase db;
private static Button BtnIAddCateg;
private static Button BtnICancelCateg;
private static final String TAG = CategorySetting.class.getSimpleName();
DatabaseHelper dBHelper = new DatabaseHelper (this);
private ListView list;
private ArrayList<String> arrTransId = new ArrayList<String>();
private ArrayList<String> arrTransName = new ArrayList<String>();
private ArrayList<String> arrTransAmount = new ArrayList<String>();
private ArrayList<String> arrTransType= new ArrayList<String>();
private ArrayList<String> arrTransDate= new ArrayList<String>();
private ArrayList<String> arrCategId= new ArrayList<String>();
private AlertDialog.Builder build;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_cashflow);
displayData();
}
//udah beres udah bisa show, tinggal action click udh bisa tp value blm pindah,,
//penggunaan Radio Button belum nanti di NewTrans
private void displayData() {
db = dBHelper.getReadableDatabase();
Cursor mCursor = db.rawQuery("SELECT * FROM " + dBHelper.TABLE_Trans_NAME, null);
list = (ListView)findViewById(android.R.id.list);
arrTransId.clear();
arrTransName.clear();
arrTransAmount.clear();
arrTransType.clear();
arrTransDate.clear();
arrCategId.clear();
if (mCursor.moveToFirst()) {
do {
arrTransId.add(mCursor.getString(mCursor.getColumnIndex(dBHelper.TOL1)));
arrTransName.add(mCursor.getString(mCursor.getColumnIndex(dBHelper.TOL2)));
arrTransAmount.add(mCursor.getString(mCursor.getColumnIndex(dBHelper.TOL3)));
arrTransType.add(mCursor.getString(mCursor.getColumnIndex(dBHelper.TOL4)));
arrTransDate.add(mCursor.getString(mCursor.getColumnIndex(dBHelper.TOL5)));
arrCategId.add(mCursor.getString(mCursor.getColumnIndex(dBHelper.TOL6)));
} while (mCursor.moveToNext());
}
DisplayAdapterTrans disadptr = new DisplayAdapterTrans(ViewCashflow.this, arrTransId, arrTransName,
arrTransAmount, arrTransType, arrTransDate, arrCategId);
list.setAdapter(disadptr);
mCursor.close();
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
//click to update data
// namanya blom diubah coeg
Intent i = new Intent(getApplicationContext(), NewTransaction.class);
i.putExtra("TransId", arrTransId.get(arg2));
i.putExtra("TransName", arrTransName.get(arg2));
i.putExtra("TransAmount", arrTransAmount.get(arg2));
i.putExtra("TransType", arrTransType.get(arg2));
i.putExtra("TransDate", arrTransDate.get(arg2));
i.putExtra("TransCategId", arrCategId.get(arg2));
i.putExtra("update", true);
startActivity(i);
}
});
}
@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_view_cashflow, 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_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
第二个 Activity
(NewTransaction
)
public class NewTransaction extends ActionBarActivity {
Button btnIDate;
Button btnIAdd;
Button btnICancel;
RadioButton RdIncome;
RadioButton RdOutcome;
EditText txtAmount, txtCashflow, txtType;
DatabaseHelper dbHelper = new DatabaseHelper(this);
SQLiteDatabase db;
MainActivity mainAct = new MainActivity();
int year_x, month_x, day_x;
static final int DIALOG_ID=0;
public static long dateSelected;
public static Integer intAmount = null;
private boolean isUpdate;
private String id, transname, transamount, transtype, transdate, transcategid;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_transaction);
txtAmount = (EditText)findViewById(R.id.txtAmount);
txtCashflow = (EditText)findViewById(R.id.txtCashflow);
txtType = (EditText)findViewById(R.id.txtType);
RdIncome = (RadioButton)findViewById(R.id.RdBtnIncome);
RdOutcome = (RadioButton)findViewById(R.id.RdBtnOutcome);
final Calendar cal = Calendar.getInstance();
year_x = cal.get(Calendar.YEAR);
month_x = cal.get(Calendar.MONTH);
day_x = cal.get(Calendar.DAY_OF_MONTH);
TextView lblIDate = (TextView)findViewById(R.id.lblDate);
lblIDate.setText("Date selected : " + year_x + "-" + month_x + "-" + day_x);
//EditText lbltxt = (EditText)findViewById(R.id.txtType);
dateSelected = (year_x+month_x+day_x);
String catSelected = mainAct.getCatSelected();
//kena null object dsni entah knapa
showDialogOnClick();
isUpdate=getIntent().getExtras().getBoolean("update");
if(isUpdate)
{
id=getIntent().getExtras().getString("TransId");
transname=getIntent().getExtras().getString("TransName");
transamount=getIntent().getExtras().getString("TransAmount");
transtype=getIntent().getExtras().getString("TransType");
transdate=getIntent().getExtras().getString("CategDate");
transcategid=getIntent().getExtras().getString("CategCategId");
txtCashflow.setText(transname);
txtType.setText(transtype);
txtAmount.setText(transamount);
}
if(RdIncome.isChecked()){
txtType.setText("Income");
}else{
txtType.setText("Outcome");
}
onButtonClickButtonListener(dateSelected, catSelected);
}
public void showDialogOnClick(){
//TextView lblIDate = (TextView)findViewById(R.id.lblDate);
btnIDate = (Button)findViewById(R.id.btnDate);
btnIDate.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
showDialog(DIALOG_ID);
}
}
);
}
@Override
protected Dialog onCreateDialog(int id){
if (id == DIALOG_ID)
return new DatePickerDialog(this, dpickerListener , year_x, month_x, day_x);
return null;
}
public DatePickerDialog.OnDateSetListener dpickerListener
= new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
TextView lblIDate = (TextView)findViewById(R.id.lblDate);
year_x= year;
month_x = monthOfYear + 1;
day_x = dayOfMonth;
lblIDate.setText("Date selected : " + year_x + "-" + month_x + "-" + day_x);
Toast.makeText(NewTransaction.this, year_x + "/" + month_x + "/" + day_x, Toast.LENGTH_LONG).show();
//DateFormat.getDateInstance().format(myDatePicker.getCalendarView().getDate());
}
};
private void clearText(){
txtCashflow.clearComposingText();
txtAmount.clearComposingText();
txtType.clearComposingText();
}
public void onButtonClickButtonListener(final long dateSelected, final String catSelected){
btnIAdd = (Button)findViewById(R.id.btnAddTrans);
btnIAdd.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
/*if(RdIncome.isChecked()){
txtType.setText("Income");
}else{
txtType.setText("Outcome");
}*/
if (isUpdate) {
//update
Toast.makeText(NewTransaction.this, "Clicked", Toast.LENGTH_LONG).show();
intAmount = Integer.parseInt(txtAmount.getText().toString());
boolean isInserted = dbHelper.updateTransData(id, txtCashflow.getText().toString(),
intAmount, txtType.getText().toString(),
dateSelected, catSelected, null);
if (isInserted == true) {
Toast.makeText(NewTransaction.this, "Inserted", Toast.LENGTH_LONG).show();
clearText();
Intent intent = new Intent(
NewTransaction.this,
ViewCashflow.class
);
startActivity(intent);
} else
Toast.makeText(NewTransaction.this, "Not Inserted", Toast.LENGTH_LONG).show();
} else {
//insert
Toast.makeText(NewTransaction.this, "Clicked", Toast.LENGTH_LONG).show();
intAmount = Integer.parseInt(txtAmount.getText().toString());
boolean isInserted = dbHelper.insertTransData(txtCashflow.getText().toString(),
intAmount, txtType.getText().toString(),
dateSelected, catSelected, null);
if (isInserted == true) {
Toast.makeText(NewTransaction.this, "Inserted", Toast.LENGTH_LONG).show();
clearText();
Intent intent = new Intent(
NewTransaction.this,
ViewCashflow.class
);
startActivity(intent);
} else
Toast.makeText(NewTransaction.this, "Not Inserted", Toast.LENGTH_LONG).show();
}
}
});
btnICancel = (Button)findViewById(R.id.btnCancelTrans);
btnICancel.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(
NewTransaction.this,
MainActivity.class
);
startActivity(intent);
}
}
);
}
@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_new_transaction_, 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_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
这是我的 CategorySetting
/ViewCategory
代码(另一个使用这种代码模式的 Activity
):
public class CategorySetting extends Activity {
private SQLiteDatabase db;
private static Button BtnIAddCateg;
private static Button BtnICancelCateg;
private static final String TAG = CategorySetting.class.getSimpleName();
DatabaseHelper dBHelper = new DatabaseHelper (this);
private ListView list;
private ArrayList<String> arrCategId = new ArrayList<String>();
private ArrayList<String> arrCategName = new ArrayList<String>();
private ArrayList<String> arrCategNote = new ArrayList<String>();
private ArrayList<String> arrCategCurr = new ArrayList<String>();
private AlertDialog.Builder build;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_category_setting);
onButtonClickButtonListener();
//ListView list = getListView();
//showListView();
displayData();
onLongClickListener();
}
private void displayData() {
db = dBHelper.getReadableDatabase();
Cursor mCursor = db.rawQuery("SELECT * FROM " + dBHelper.TABLE_Categ_NAME, null);
list = (ListView)findViewById(android.R.id.list);
arrCategId.clear();
arrCategName.clear();
arrCategNote.clear();
arrCategCurr.clear();
if (mCursor.moveToFirst()) {
do {
arrCategId.add(mCursor.getString(mCursor.getColumnIndex(dBHelper.COL1)));
arrCategName.add(mCursor.getString(mCursor.getColumnIndex(dBHelper.COL2)));
arrCategNote.add(mCursor.getString(mCursor.getColumnIndex(dBHelper.COL3)));
arrCategCurr.add(mCursor.getString(mCursor.getColumnIndex(dBHelper.COL4)));
} while (mCursor.moveToNext());
}
DisplayAdapter disadpt = new DisplayAdapter(CategorySetting.this, arrCategId, arrCategName, arrCategId, arrCategCurr);
list.setAdapter(disadpt);
mCursor.close();
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
//click to update data
Intent i = new Intent(getApplicationContext(), AddCategory.class);
i.putExtra("CategId", arrCategId.get(arg2));
i.putExtra("CategName", arrCategName.get(arg2));
i.putExtra("CategNote", arrCategNote.get(arg2));
i.putExtra("CategCurr", arrCategCurr.get(arg2));
i.putExtra("update", true);
startActivity(i);
}
});
}
private void onLongClickListener(){
ListView list = (ListView)findViewById(android.R.id.list);
list.setOnItemLongClickListener(new OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int arg2, long arg3) {
build = new AlertDialog.Builder(CategorySetting.this);
build.setTitle("Delete " + arrCategName.get(arg2));
build.setMessage("Do you want to delete ?");
build.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText( getApplicationContext(),
arrCategName.get(arg2) + " is deleted.", Toast.LENGTH_LONG).show();
db.delete(
dBHelper.TABLE_Categ_NAME, dBHelper.COL1 + "=" + arrCategId.get(arg2), null);
displayData();
dialog.cancel();
}
});
build.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alert = build.create();
alert.show();
return true;
}
});
}
//ListView view = getListView();
//iew.addHeaderView(getLayoutInflater().inflate(R.layout.trans, null));
//db = dBHelper.getWritableDatabase();
//this.muat_ulang();
/*public void reload(){
try {
DatabaseHelper dbHelper = new DatabaseHelper(this.getApplicationContext());
db = dbHelper.getWritableDatabase();
Cursor c = db.rawQuery("SELECT CategName FROM " + tableName, null);
if (c != null ) {
if (c.moveToFirst()) {
do {
String categName = c.getString(c.getColumnIndex("CategName"));
}while (c.moveToNext());
}
}
} catch (SQLiteException se ) {
Log.e(getClass().getSimpleName(), "Could not create or Open the database");
} finally {
if (db != null)
db.execSQL("DELETE FROM " + tableName);
db.close();
}
}*/
@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_category_setting, menu);
return true;
}
public void onButtonClickButtonListener(){
BtnIAddCateg = (Button)findViewById(R.id.btnAddNewCateg);
BtnIAddCateg.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentAddCateg = new Intent ("com.example.ever_ncn.cashflow.AddCategory");
intentAddCateg.putExtra("update", false);
startActivity(intentAddCateg);
startActivity(intentAddCateg);
}
}
);
BtnICancelCateg = (Button)findViewById(R.id.btnCancelCateg);
BtnICancelCateg.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(
CategorySetting.this,
MainActivity.class
);
startActivity(intent);
}
}
);
}
@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_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
这一个用于 AddCategory
:
public class AddCategory extends ActionBarActivity {
private static Button BtnIAdd;
private static Button BtnICancel;
EditText txtcategname, txtType;
Spinner selectCurrency;
ArrayAdapter<CharSequence> adapterCurrency;
DatabaseHelper DbHelper = new DatabaseHelper(this);
SQLiteDatabase db;
private boolean isUpdate;
private String id, categname, categnote, categcurr;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_category);
txtcategname = (EditText)findViewById(R.id.editText);
txtType = (EditText)findViewById(R.id.editText2);
BtnICancel = (Button)findViewById(R.id.btnCancel);
BtnIAdd = (Button)findViewById(R.id.btnAdd);
//spinner
selectCurrency = (Spinner) findViewById(R.id.spin_selectCurrency);
adapterCurrency = ArrayAdapter.createFromResource(this, R.array.CurrencyName,android.R.layout.simple_spinner_item );
adapterCurrency.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
selectCurrency.setAdapter(adapterCurrency);
selectCurrency.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getBaseContext(), parent.getItemAtPosition(position) + " selected", Toast.LENGTH_LONG).show();
String currencyValue = String.valueOf(parent.getSelectedItem());
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
isUpdate=getIntent().getExtras().getBoolean("update");
if(isUpdate)
{
id=getIntent().getExtras().getString("CategId");
categname=getIntent().getExtras().getString("CategName");
categnote=getIntent().getExtras().getString("CategNote");
categcurr=getIntent().getExtras().getString("CategCurr");
txtcategname.setText(categname);
txtType.setText(categnote);
}
addCategData();
}
@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_add_category, menu);
return true;
}
public void addCategData(){
BtnIAdd.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(AddCategory.this, "Clicked", Toast.LENGTH_LONG).show();
db=DbHelper.getWritableDatabase();
ContentValues values=new ContentValues();
values.put(DbHelper.COL2,categname );
values.put(DbHelper.COL3,categnote );
values.put(DbHelper.COL4,categcurr );
System.out.println("");
if(isUpdate)
{
//update database with new data
boolean isInserted = DbHelper.updateCategData(Integer.parseInt(id), txtcategname.getText().toString(),
txtType.getText().toString(), selectCurrency.getSelectedItem().toString(), null);
if (isInserted == true) {
Toast.makeText(AddCategory.this, "Updated", Toast.LENGTH_LONG).show();
//baru sampe dsni
Intent intent = new Intent(
AddCategory.this,
CategorySetting.class
);
startActivity(intent);
} else
Toast.makeText(AddCategory.this, "Not Inserted", Toast.LENGTH_LONG).show();
}
else
{
//insert data into database
boolean isInserted = DbHelper.insertCategData(txtcategname.getText().toString(),
txtType.getText().toString(), selectCurrency.getSelectedItem().toString(), null);
if (isInserted == true) {
Toast.makeText(AddCategory.this, "Inserted", Toast.LENGTH_LONG).show();
//baru sampe dsni
Intent intent = new Intent(
AddCategory.this,
CategorySetting.class
);
startActivity(intent);
} else
Toast.makeText(AddCategory.this, "Not Inserted", Toast.LENGTH_LONG).show();
}
//close database
db.close();
finish();
}
}
);
BtnICancel.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
}
);
}
@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_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
最佳答案
发生这种情况是因为当您直接开始第二个 Activity NewTransaction
时,您没有将 extras
放入 intent
中,因此当您调用getIntent().getExtras();
它返回一个 null
对象,这就是为什么 getIntent().getExtras().getBoolean("update");
抛出 NPE。
作为解决方案:尝试在获取数据之前检查 getIntent().getExtras() != null
,这将解决您的问题。
Bundle bundle= getIntent().getExtras();
if (bundle!= null) {// to avoid the NullPointerException
isUpdate=bundle.getBoolean("update");
if(isUpdate)
{
id=bundle.getString("TransId");
transname=bundle.getString("TransName");
transamount=bundle.getString("TransAmount");
transtype=bundle.getString("TransType");
transdate=bundle.getString("CategDate");
transcategid=bundle.getString("CategCategId");
txtCashflow.setText(transname);
txtType.setText(transtype);
txtAmount.setText(transamount);
}
}
关于java - Android.os.Bundle 上的 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32031178/
我正在将我的模板代码移植到 XTend。在某些时候,我在测试用例中有这种类型的条件处理: @Test def xtendIfTest() { val obj = new FD if (
我是新来的 kotlin , 当我开始 Null Safety 时,我对下面的情况感到困惑. There's some data inconsistency with regard to initia
我的应用程序一直在各种Android版本中保持良好状态。我有用户在Android 4.3、5.0、5.1和6.0上正常运行。但是,具有S7 Edge的用户刚刚更新了Android 7.0,将文本粘贴到
我使用的是最新版本的 LWUIT (1.5)。我在资源编辑器中设计了我的表单,然后将代码生成到 netbeans。问题是如果我想访问除表单之外的任何对象,我会收到此错误: java.lang.Null
更新: 我在 Fedora 21 上运行它。 SonarQube - 5.0。 SonarQube Runner - 2.4 更新 2:Findbugs v3.1,Java 插件 v2.8 更新3:
RecupData 我的类仅在 web 中返回 NullPointerException。我连接到 pgsql db 8.3.7 - 该脚本在“控制台”syso 中运行良好 - 但引发了测试 Web
我在 mac 上使用 Processing 2.08。我正在尝试使用文档中给出的 createShape 函数创建 PShape。 PShape s; void setup(){ size(500
我在 mac 上使用 Processing 2.08。我正在尝试使用文档中给出的 createShape 函数创建 PShape。 PShape s; void setup(){ size(500
每次运行此 jsp 时,都会收到以下错误异常: org.apache.jasper.JasperException: java.lang.NullPointerException root cause
Kotlin 在编译时有一个出色的 null 检查,使用分离到“可空?”和“不可为空”的对象。它有一个 KAnnotator 来帮助确定来自 Java 的对象是否可以为空。但是,如果 not-null
我有一个布局将显示一个TextView,用于显示一个滴答时间。我遵循了此链接中的代码 How to Display current time that changes dynamically for
Elasticsearch 1.4.1版(“lucene_version”:“4.10.2”) 我有一个像这样的文件: $ curl 'http://localhost:9200/blog/artic
这是我从另一个类调用函数的方法Selenium 设置已定义。 public void Transfer() throws Exception { System.out.println("\nTrans
我试图在主类中使用我在此类中创建的函数,但它崩溃并显示“警告:无法在根 0 处打开/创建首选项根节点 Software\JavaSoft\Prefsx80000002。 Windows RegCrea
这个问题已经有答案了: What is a NullPointerException, and how do I fix it? (12 个回答) 已关闭 3 年前。 我有一个 Java 代码,它将
我声明了两张牌: Card card1 = new Card('3', Card.Suit.clubs); Card card2 = new Card('T', Card.Suit.diamonds)
我编写了一段代码来解码 Base64 图像并在 javafx 中表示该图像。在我的 url base64 代码中不断变化。这就是我在 javafx 代码中使用任务的原因。但我收到错误:java.lan
我正在尝试使用 arrayList 的 arrayList 在 Java 中实现图形。 每当调用 addEdge 函数时,我都会收到 NullPointerException 。我似乎无法弄清楚为什么
我是 Java/android 的新手,所以很多这些术语都是外国的,但我愿意学习。我不打算详细介绍该应用程序,因为我认为它不相关。我目前的问题是,我使用了博客中的教程和代码 fragment ,并使我
我正在开发一个 Android 应用程序来在 Android developer guide 的帮助下录制视频.我程序上的所有代码都与此页面相同。 我在 之外定义了权限标签。 当应
我是一名优秀的程序员,十分优秀!