titi9000000

توسعه دهنده اندروید
  • تعداد ارسال ها

    7
  • تاریخ عضویت

  • آخرین بازدید

اعتبار در انجمن

0 Neutral

درباره titi9000000

  • درجه
    Newbie
  1. 06-19 03:09:35.192 1819-1819/com.example.mostafa.myapplication E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.mostafa.myapplication, PID: 1819 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mostafa.myapplication/com.example.mostafa.myapplication.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at com.example.mostafa.myapplication.MainActivity.onCreate(MainActivity.java:19) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method)
  2. سلام.دوستان.این برنامه نوشتم.چرا موقع اجرا ارور میده؟تو برنامه هیچ خطایی نمیده؟ android.app.ActivityThread.-wrap11(ActivityThread.java) android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) lkg من layout تعریف کردم. public class Form_Info implements View.OnClickListener, CompoundButton.OnCheckedChangeListener { private EditText inputName; private EditText inputPhone; private EditText inputEmail; private CheckBox cbSharePhone; private Button btnSubmit; private Activity activity; private LinearLayout layout_FormInfo; public Form_Info(Activity activity, int layoutId) { this.activity = activity; this. layout_FormInfo = (LinearLayout) activity.findViewById(layoutId); //inIt(); if (layout_FormInfo == null) { return; } } private void inIt() { inputName = (EditText) layout_FormInfo.findViewById(R.id.input_Name); inputEmail = (EditText) layout_FormInfo.findViewById(R.id.input_email); inputPhone = (EditText) layout_FormInfo.findViewById(R.id.input_phone); cbSharePhone = (CheckBox) layout_FormInfo.findViewById(R.id.Cb_Share_Phone); btnSubmit = (Button) layout_FormInfo.findViewById(R.id.btn_submit); btnSubmit.setOnClickListener(this); cbSharePhone.setOnCheckedChangeListener(this); } public EditText getInputName() { return inputName; } public EditText getInputPhone() { return inputPhone; } public EditText getInputEmail() { return inputEmail; } public CheckBox getCbSharePhone() { return cbSharePhone; } public Button getBtnSubmit() { return btnSubmit; } @Override public void onClick(View view) { if (view.getId() == btnSubmit.getId()) { String email = inputEmail.getText().toString().trim(); String phone = inputPhone.getText().toString().trim(); String name = inputName.getText().toString().trim(); if (isValidInput(name, phone, email)) { Intent intent =new Intent(activity,SecondActivity.class); if(cbSharePhone.isChecked()) { intent.putExtra("phone", phone); } intent.putExtra("name", name); intent.putExtra("email", email); activity.startActivity(intent); } } } @Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { if (compoundButton.getId() == cbSharePhone.getId()) { inputPhone.setEnabled(isChecked); } } public boolean isValidInput(String name, String phone,String email) { if(name==null) name=inputName.getText().toString(); if(phone==null) phone=inputPhone.getText().toString(); if (email==null) email=inputEmail.getText().toString(); if (name.length() < 3) { Toast.makeText(activity, "name should be at least 3 characters", Toast.LENGTH_SHORT).show(); inputName.requestFocus(); return false; } if (! phone.isEmpty() &&(phone.length()!=11 || !phone .startsWith("09")) ){ Toast.makeText(activity, "wrong number", Toast.LENGTH_SHORT).show(); inputPhone.requestFocus(); return false; } if (!email.contains("@")||email.lastIndexOf('.')<email.lastIndexOf('@')){ Toast.makeText(activity, "wrong email address", Toast.LENGTH_SHORT).show(); inputPhone.requestFocus(); return false; } return true; } } public class MainActivity extends AppCompatActivity { public static final int REQ_Code=12; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final Form_Info form=new Form_Info(this,R.id.layout_form_info); form.getBtnSubmit().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String name=form.getInputName().getText().toString().trim(); String email=form.getInputEmail().getText().toString().trim(); String phone=form.getInputPhone().getText().toString().trim(); if(form.isValidInput(name,email,phone)){ Intent intent=new Intent(MainActivity.this,SecondActivity.class); intent.putExtra("name",name); intent.putExtra("email",email); if(form.getCbSharePhone().isChecked()){ intent.putExtra("phone", phone); } startActivityForResult(intent,REQ_Code); } } }); } }
  3. لام.چرا این برنامه من موقع اجرا اون پیغام میده؟چه کدی باید بهش package mostafa.com.customdialog1; import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.renderscript.Sampler; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.view.Window; import android.widget.Button; public class MainActivity extends Dialog implements View.OnClickListener { public Activity c; public Button yes , no; public Dialog d; public MainActivity(Activity a) { super(a); this.c=a; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.custom_dialog); d.show(); yes=(Button)findViewById(R.id.btn_yes); no=(Button)findViewById(R.id.btn_no); yes.setOnClickListener(this); no.setOnClickListener(this); } @Override public void onClick(View v) { switch (v.getId()){ case R.id.btn_yes: c.finish(); break; case R.id.btn_no: dismiss(); break; default: break; } dismiss(); } } اضافه بشه؟
  4. کلاس G در اندروید منیفست شناساندم. G.java MainActivity.java
  5. سلام.چرااین برنامه را در شبیه ساز اجرا می کنم.cant play video میزنه؟ Video_Player.zip
  6. سلام.دوستان.من intellij نسخه 15 را نصب کردم.روی utf-8 هست.ولی نمیتونم فارسی بنویسیم.چطور مشکلش حل کنم؟
  7. سلام.یک سوال داشتم.چرا این برنامه موقع اجرا ارور میگیره.مشکلش چیه؟چطور میشه حل کرد؟ public static void main (String[]args){ int row,col; Scanner sc=new Scanner(System.in); int[][]g=new int[2][3]; System.out.println("please input rows"); row=sc.nextInt(); System.out.println("please input columns"); col=sc.nextInt(); System.out.println("enter"+(row*col)+"array elements"); for (int i=0;i<row;i++) { for (int j = 0; j < row; j++) g[row][col] = sc.nextInt(); } System.out.println("the array is"); for(int i=0;i<row;i++){ for (int j = 0; j < row; j++) { System.out.println(g[i][j]); } } }