Created
July 11, 2011 23:17
-
-
Save arnaudbos/1077027 to your computer and use it in GitHub Desktop.
(Android)Extended item view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<selector | |
xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item android:state_focused="true" > | |
<shape> | |
<gradient | |
android:startColor="@color/blue" | |
android:endColor="@color/blue"/> | |
<stroke | |
android:width="0dp" | |
android:color="@color/blue" /> | |
</shape> | |
</item> | |
<item android:state_focused="true" android:state_pressed="true"> | |
<shape> | |
<gradient | |
android:startColor="@color/blue" | |
android:endColor="@color/blue"/> | |
<stroke | |
android:width="0dp" | |
android:color="@color/blue" /> | |
</shape> | |
</item> | |
<item android:state_pressed="true"> | |
<shape> | |
<gradient | |
android:startColor="@color/blue" | |
android:endColor="@color/blue"/> | |
<stroke | |
android:width="0dp" | |
android:color="@color/blue" /> | |
</shape> | |
</item> | |
<item> | |
<shape> | |
<gradient | |
android:startColor="@color/green" | |
android:endColor="#71A100" | |
android:angle="-90"/> | |
<stroke | |
android:width="2dp" | |
android:color="@color/background" /> | |
</shape> | |
</item> | |
</selector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package uk.ac.brookes.arnaudbos.luscinia.widget; | |
import uk.ac.brookes.arnaudbos.luscinia.R; | |
import android.content.Context; | |
import android.graphics.drawable.Drawable; | |
import android.view.LayoutInflater; | |
import android.widget.ImageView; | |
import android.widget.RelativeLayout; | |
import android.widget.TextView; | |
public class DocumentView extends RelativeLayout | |
{ | |
private LayoutInflater inflater; | |
private RelativeLayout documentView; | |
private ImageView documentPicture; | |
private TextView documentText; | |
public DocumentView(Context context, Drawable icon, String text, OnClickListener listener) | |
{ | |
super(context); | |
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | |
documentView = (RelativeLayout) inflater.inflate(R.layout.folder_document_item, null); | |
addView(documentView); | |
documentPicture = (ImageView) documentView.findViewById(R.id.document_picture); | |
documentPicture.setImageDrawable(icon); | |
documentText = (TextView) documentView.findViewById(R.id.document_name); | |
documentText.setText(text); | |
if(listener!=null) | |
{ | |
documentView.setOnClickListener(listener); | |
} | |
} | |
public void setIcon(Drawable icon) | |
{ | |
documentPicture.setImageDrawable(icon); | |
} | |
public void setText(String text) | |
{ | |
documentText.setText(text); | |
} | |
@Override | |
public void setOnClickListener(OnClickListener l) | |
{ | |
documentView.setOnClickListener(l); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="154dp" | |
android:layout_height="154dp" | |
android:gravity="center" | |
android:clickable="true" | |
android:background="@drawable/document_list_selector"> | |
<ImageView | |
android:layout_height="150dp" | |
android:layout_width="150dp" | |
android:id="@+id/document_picture" | |
android:layout_alignParentTop="true" | |
android:scaleType="centerCrop" | |
> | |
</ImageView> | |
<LinearLayout | |
android:orientation="vertical" | |
android:gravity="center" | |
android:layout_height="60dp" | |
android:layout_width="150dp" | |
android:layout_alignParentBottom="true" | |
android:background="#80000000" | |
android:layout_marginLeft="2dip" | |
android:layout_marginBottom="4dip" | |
android:layout_marginRight="2dip" | |
> | |
<TextView | |
android:layout_height="wrap_content" | |
android:text="Name" | |
android:layout_width="wrap_content" | |
android:id="@+id/document_name" | |
android:textSize="14dp" | |
android:textStyle="bold" | |
android:textColor="@color/background" | |
android:scrollHorizontally="false" | |
> | |
</TextView> | |
</LinearLayout> | |
</RelativeLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment