2016-04-24 6 views
-1

私のプログラム内に「button1」という名前のボタンがあります。プログラムをクリックすると、何も起こりません。プログラムはAjouteNouveauArticleクラスに電話すると思います。私はエミュレータ上でアプリケーションを実行するとインテントが私のために機能しない

はまた、私はこのエラーが表示されます。

getSlotFromBufferLocked: unknown buffer: 0xa17a7690 

間違っているのですか?

私のプログラム:

public class PageAccueil extends AppCompatActivity { 
    public static ArrayList< ToolType> ToolType = new ArrayList<ToolType>();//llist tol type 
    AQuery aq; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_page_accueil); 
     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
     setSupportActionBar(toolbar); 

    } 
    public void next(View view){ 

     Intent intent1=new Intent(this,MotPasseOublier.class); 
     startActivity(intent1); 
    }} 

そして、これは私がボタン1で押したときに呼び出さしたい第二クラスです:

public class AjouteNouveauArticle extends Activity { 
     String TempToolID; 
     GridView ls; 
     MyCustomAdapter myadapter; 
     Spinner spinner ; 
     AQuery aq; 
     ArrayList<AjouteImage> fullsongpath =new ArrayList<AjouteImage>(); 

     int RESULT_LOAD_IMAGE=1; 
     public Bitmap bitmap; // the selected image from gellary 


     @Override 
     protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.activity_ajoute_nouveau_article); 
      final Random rand = new Random(); 
      String diceRoll =String.valueOf(rand.nextInt(7000000) + 5000); 
      TempToolID=EnrigistrementDonnee.UserID+ "000000"+ diceRoll ; 

      // initialize the gridview 
      fullsongpath.add(new AjouteImage("NewImage", R.drawable.cloud,null)); 
      ls=(GridView)findViewById(R.id.gridView); 
      myadapter=new MyCustomAdapter(fullsongpath); 
      ls.setAdapter(myadapter); 
      aq=new AQuery(this); 
      spinner = (Spinner)findViewById(R.id.spinner); 


    // Array of choices // still didinot load data 
      if(PageAccueil.ToolType.size()==0) { 

       this.finish(); 
       return; 
      } 
      String[] ToolTypeArray = new String[PageAccueil.ToolType.size()]; 
      for (int i = 0; i < PageAccueil.ToolType.size(); i++) { 
       ToolTypeArray[i] = PageAccueil.ToolType.get(i).ToolTypeName; 
      } 
      ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, ToolTypeArray); 
      spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // The drop down view 
      spinner.setAdapter(spinnerArrayAdapter); 
     } 

     @Override 
     protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
      super.onActivityResult(requestCode, resultCode, data); 
      if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) { 
       //loading images 
       int index = fullsongpath.size() - 1; 
       if (index < 0) 
        index = 0; 
       fullsongpath.remove(index); 
       myadapter.notifyDataSetChanged(); 

       ImageView IVADDPIC=new ImageView(this); 
       Uri selectedImage = data.getData(); 
       String[] filePathColumn = { MediaStore.Images.Media.DATA }; 
       Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); 
       cursor.moveToFirst(); 
       int columnIndex = cursor.getColumnIndex(filePathColumn[0]); 
       String picturePath = cursor.getString(columnIndex); 
       cursor.close(); 
       IVADDPIC.setImageBitmap(BitmapFactory.decodeFile(picturePath)); 
       //load images 
       BitmapDrawable drawable = (BitmapDrawable) IVADDPIC.getDrawable(); 
       Bitmap largeBitmap = drawable.getBitmap(); 
       int h = 600; // height in pixels 
       int w = 600; // width in pixels 
       bitmap= Bitmap.createScaledBitmap(largeBitmap, h, w, true); 
       ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
       bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); 
       byte[] Imagedata = baos.toByteArray(); 
       // ImageView image=new ImageView(this); 
       // image.setImageBitmap(bitmap); 
       String encodedImageData = Base64.encodeToString(Imagedata, 0); 

       Map<String, Object> params = new HashMap<>(); 
       params.put("image", encodedImageData); 
       params.put("TempToolID", TempToolID); 
       String url=EnrigistrementDonnee.ServerURL +"Uses.asmx"; 
       new MyAsyncGetNewNews().execute(url,encodedImageData,TempToolID); 
      } 
     } 

     public void buAddTool(View view) { 
      Toast.makeText(getApplicationContext(),String.valueOf(spinner.getSelectedItemPosition()),Toast.LENGTH_LONG).show(); 
      EditText ToolName=(EditText)findViewById(R.id.EDTToolName); 
      EditText ToolDes=(EditText)findViewById(R.id.EDToolDes); 
      EditText ToolPrice=(EditText)findViewById(R.id.EDTToolPrice); 
      //validate user info 
      if((ToolName.getText().length()<2)||(ToolDes.getText().length()<2) ||(ToolPrice.getText().length()<2)) { 

       // Operations.DisplayMessage(this, getResources().getString(R.string.AddAllinfo)); 

       return; 
      } 
    // check if he added images 
      if(AddImagesPlease==0){ 
      // Operations.DisplayMessage(this, getResources().getString(R.string.AddImagesPlease)); 

       return; 
      } 

      String url = EnrigistrementDonnee.ServerURL +"aspnet_client"+"/Service"+"/Uses.asmx"+"/AddTolls?UserID="+ EnrigistrementDonnee.UserID+" &ToolName="+ToolName.getText()+"&ToolDes="+ ToolDes.getText()+"&ToolPrice="+ToolPrice.getText()+"&ToolTypeID="+String.valueOf(PageAccueil.ToolType.get(spinner.getSelectedItemPosition()).ToolTypeID) +"&TempToolID=" + String.valueOf(TempToolID); 

      aq.ajax(url, JSONObject.class, this, "jsonCallback"); 

     } 
     public void jsonCallback(String url, JSONObject json, AjaxStatus status) throws JSONException { 

      if(json != null){ 
       //successful ajax call 
       //successful ajax call 
       String msg=json.getString("Message"); 
       Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show(); 
       int IsAdded=json.getInt("IsAdded"); 
       if(IsAdded!=0){ // mean the tool is added go to manage tool later 
        // Intent myintents = new Intent(getApplicationContext(), MyTool.class); 
        // startActivity(myintents); 
       } 
      }else{ 
       //ajax error 
      } 

     } 
     int AddImagesPlease=0; //number of images that added 
     // send image to the webservice 
     public class MyAsyncGetNewNews extends AsyncTask<String, String, String> { 
      @Override 
      protected void onPreExecute() { 

      } 
      @Override 
      protected String doInBackground(String... params) { 
       final String NAMESPACE = "http://tempuri.org/"; 
       final String URL = params[0]; 
       final String METHOD_NAME = "UploadImage"; 
       final String SOAP_ACTION = "http://tempuri.org/UploadImage"; 
       SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

       request.addProperty("image", params[1]); 
       request.addProperty("TempToolID",params[2]); 


       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 

       envelope.dotNet = true; 
       envelope.setOutputSoapObject(request); 
       HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 


       try{ 
        androidHttpTransport.call(SOAP_ACTION, envelope); 
        Object obj = envelope.bodyIn; 
        SoapObject result = (SoapObject) envelope.getResponse(); 

       } 

       catch(Exception e){ 
        e.printStackTrace(); 
       } 

       return null; 
      } 
      protected void onProgressUpdate(String... progress) { 




      } 
      protected void onPostExecute(String result2){ 
       int index=fullsongpath.size() - 1; 
       if(index<0) 
        index=0; 
       fullsongpath.remove(index); 
       fullsongpath.add(index, new AjouteImage("NewImage", R.drawable.cloud, null)); 
       myadapter.notifyDataSetChanged(); 
       ls.smoothScrollToPosition(fullsongpath.size() - 1); 
       AddImagesPlease=AddImagesPlease+1; 
      } 

     } 

リソースファイル:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 

    tools:context="com.mstr.malik.myProject.AjouteNouveauArticle"> 
    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"> 

     <LinearLayout 

      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:paddingRight="10dp" 
      android:paddingTop="10dp"> 

      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/LLogin" 
       android:layout_marginTop="7dp" 
       android:paddingLeft="4dp" 
       android:paddingTop="4dp"> 


       <LinearLayout 
        android:orientation="vertical" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:touchscreenBlocksFocus="false" 
        android:layout_marginBottom="2dp"> 

        <EditText 
         android:maxLength="35" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:inputType="text" 
         android:ems="10" 
         android:id="@+id/EDTToolName" 
         android:layout_weight="1" 
         android:textColor="#ff1a102c" 

         android:textSize="18dp" 
         android:paddingBottom="9dp" 
         android:paddingTop="9dp" 
         android:layout_marginBottom="10dp"/> 
       </LinearLayout> 

       <LinearLayout 
        android:orientation="vertical" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:touchscreenBlocksFocus="false" 
        android:layout_marginBottom="2dp"> 

        <EditText 
         android:inputType="textMultiLine" 
         android:singleLine="false" 
         android:maxLength="400" 
         android:maxLines="4" 
         android:lines="4" 
         android:layout_width="fill_parent" 
         android:layout_height="100dp" 
         android:ems="10" 
         android:id="@+id/EDToolDes" 
         android:layout_weight="1" 
         android:textColor="#ff1a102c" 

         android:textSize="18dp" 
         android:paddingBottom="9dp" 
         android:paddingTop="9dp" 
         android:layout_marginBottom="10dp" 
         /> 

       </LinearLayout> 

       <LinearLayout 
        android:gravity="right" 
        android:orientation="vertical" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:touchscreenBlocksFocus="false" 
        android:layout_marginBottom="2dp"> 

        <EditText 
         android:maxLength="15" 
         android:layout_width="70pt" 
         android:layout_height="wrap_content" 
         android:ems="10" 
         android:id="@+id/EDTToolPrice" 
         android:layout_weight="1" 
         android:textColor="#ff1a102c" 
         android:textSize="18dp" 
         android:paddingBottom="9dp" 
         android:paddingTop="9dp" 
         android:layout_marginBottom="10dp" 
         android:inputType="number" /> 
       </LinearLayout> 

       <LinearLayout 

        android:layoutDirection="rtl" 
        android:orientation="horizontal" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 

        android:layout_marginBottom="15dp" 
        android:layout_marginTop="5dp"> 

        <TextView 

         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="tool type" 
         android:id="@+id/textView" 
         android:layout_weight="0" 
         android:textColor="#000000" 
         android:textSize="16dp" 
         android:textStyle="bold" /> 
        <Spinner 
         android:id="@+id/spinner" 
         android:layout_width="150dp" 
         android:layout_height="wrap_content" /> 

       </LinearLayout> 

      </LinearLayout> 

      <LinearLayout 
       android:layoutDirection="rtl" 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="click to add image" 
        android:id="@+id/textView2" /> 

       <GridView 
        android:background="#ffffff" 
        android:horizontalSpacing="5dp" 
        android:verticalSpacing="5dp" 
        android:columnWidth="110dp" 

        android:numColumns="auto_fit" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/gridView" /> 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="AddTool" 
        android:drawablePadding="2dp" 
        android:id="@+id/BuSaveSetting" 
        android:background="@drawable/register_button" 
        android:layout_marginBottom="10dp" 
        android:textColor="#ff06071c" 
        android:onClick="buAddTool" 
        android:layout_weight="0" 
        android:layout_marginLeft="15dp" 
        android:layout_marginTop="15dp" /> 

      </LinearLayout> 

     </LinearLayout> 
    </ScrollView> 
</RelativeLayout> 
+0

あなたはどこにでも 'next'メソッドを呼び出しませんでした。 –

+0

ボタンのためのものですonClick = "next" –

+0

あなたはメソッドが呼び出され、あなたは 'MotPasseOublier'アクティビティを持っていますか? –

答えて

0

PageAccueilアクティビティのonCreate関数内で、ボタン上のクリックリスナを初期化する必要があります。

Button button = (Button)findViewById(R.id.BuSaveSetting); 
button.setOnClickListener(new OnClickListener(){ 
    @Override 
    public void onClick(View v){ 
     next(v); 
    } 
}); 
+0

私はそれを作ったが、他の方法で、私はbutton OnClick = "next" –

関連する問題