Ich versuche, den Effekt zu erhalten klicken Hintergrundfarbe für lineares Layout. Ich habe ein anklickbares lineares Layout eingestellt. und aus dem code habe ich auch den click listener die setBackgroundResource gesetzt.Klicken Sie zuerst auf Linearlayout Doesn Flash-Hintergrund klicken Sie auf Farbe, es blinkt nur für den zweiten und nächsten Klick
Hier ist es das xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="@+id/llinsertmem"
android:clickable="true"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50px">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="PUSH it"
/>
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
und der Java-Code:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout linearInsertMem = (LinearLayout)findViewById(R.id.llinsertmem);
linearInsertMem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
v.setBackgroundResource(android.R.drawable.list_selector_background);
Toast.makeText(testdoank.this, "succeded", Toast.LENGTH_SHORT)
.show();
}
});
}
Wenn er zum ersten Mal den klickbaren Linearlayout klicken, wird der Toast Text angezeigt, aber die Hintergrundfarbe Klickeffekt doesn‘ t. Die Flash-Hintergrund-Klickfarbe ist nur Arbeit vom zweiten Klick.
keine Ahnung, was das Problem ist?