2017-03-24 12 views
0

laden, wenn ich auf den Button klicken, mein Image Auto verschwindet und nichts anderes auftaucht:Klicken Sie auf die Schaltfläche Bild wird nicht

Ich habe diese Ansicht:

<ImageView 
    android:id="@+id/Background" 
    android:layout_width="646dp" 
    android:layout_height="313dp" 
    app:srcCompat="@mipmap/ic_launcher_round" 
    android:contentDescription="" 
    android:layout_marginRight="-111dp" 
    android:layout_marginBottom="0dp" 
    tools:ignore="ContentDescription,RtlHardcoded" /> 

<ImageView 
    android:id="@+id/wheel" 
    android:layout_width="646dp" 
    android:layout_height="313dp" 
    app:srcCompat="@mipmap/ic_launcher_round" 
    android:contentDescription="" 
    android:layout_marginRight="-111dp" 
    android:layout_marginBottom="0dp" 
    tools:ignore="ContentDescription,RtlHardcoded" /> 

<ImageView 
    android:id="@+id/car" 
    android:layout_width="646dp" 
    android:layout_height="313dp" 
    app:srcCompat="@mipmap/ic_launcher_round" 
    android:contentDescription="" 
    android:layout_marginRight="-111dp" 
    android:layout_marginBottom="0dp" 
    tools:ignore="ContentDescription,RtlHardcoded" /> 

<Button 
    android:id="@+id/button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Button" 
    tools:layout_editor_absoluteY="113dp" 
    tools:layout_editor_absoluteX="0dp" /> 

Und dieses mainActivity:

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

    background = (ImageView)findViewById(R.id.Background); 
    wheel = (ImageView)findViewById(R.id.wheel); 
    car = (ImageView)findViewById(R.id.car); 

    Button button = (Button) findViewById(R.id.button); 
    button.setOnClickListener(new View.OnClickListener(){ 
     public void onClick(View v){ 
      image2();   } 
    }); 

    Picasso.with(getApplicationContext()).load("http://i.imgur.com/OrletzA.png").into(background); 
    Picasso.with(getApplicationContext()).load("http://i.imgur.com/qfOQnLO.png").into(wheel); 
    Picasso.with(getApplicationContext()).load("http://i.imgur.com/AjvZ7vJ.png").into(car); 
} 

public void image2(){ 
    Picasso.with(getApplicationContext()).load("http://i.imgur.com/OJ4XCYu.png").into(car); 
} 

ich versuche, diese Methode von Picasso zu sehen, ob ich einen Fehler haben:

Picasso.with(getApplicationContext()).setLoggingEnabled(true); 

Aber nichts.

Vor Klicken auf enter image description here

Nach einem Klick enter image description here

Was kann ich tun, um es zu beheben?

+0

Alles, was in der logcat? Hast du vergessen, die INTERNET-Erlaubnis im Manifest zu erklären? – Egor

+0

Wie Sie in dem „Vor Klicken“ und „nach Klick“ Bild in der Frage sehen können, kann ich ein paar Bilder sehen. aber wenn ich auf den Knopf klicke, verschwindet mein Bildansicht "Auto" und zeigt nur den Hintergrund und das Rad an. – tigie11

+0

Nichts scheint in Ihrem Code falsch zu sein, soweit ich weiß. Zeigen Sie Ihr Protokoll an. Die Bilder sind möglicherweise zu groß, um geladen zu werden, und Ihr Speicher wird voll. Versuchen Sie, die Größe zu ändern oder kleinere Bilder zu verwenden. Versuchen Sie auch mit anderen kleinen Bildern, um sicherzustellen, dass das Problem nicht bei diesen Bildern liegt. – zed

Antwort

0

Ich teste mein Programm mit einem Emulator (Android Studio). Wenn ich den Emulator herunterfahre, ist es Arbeit.

Haben Sie eine Ahnung, warum?

Verwandte Themen