Example- CheckedTextView In Android ?
In this blog explain how to work CheckedTextView Widgets in android. the CheckedTextView Added API 1 . An extension to textview that support The checkble Interface and display.
this is used in Listview where in SinglechoiceMode .
android:checkMark - Drawable used for the check mark graphic .
android:checkMarkTint - Tint to apply check mark.
android:checkMarkTintMode- Blending Mode used to apply tint check Mark.
content_main.xml
...................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#ffffff" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:layout_gravity="center"
android:src="@drawable/my_heder_img">
</ImageView>
<CheckedTextView
android:layout_width="fill_parent"
android:layout_marginTop="50dp"
android:layout_marginLeft="10dp"
android:textSize="18dp"
android:layout_height="wrap_content"
android:text="CheckedTextView"
android:id="@+id/checkedTextView"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:checked="false" /> </LinearLayout>
...................................................................................................................................................................
MainActivity.Java
...................................................................................................................................................................
import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.CheckedTextView; public class MainActivity extends Activity { @Override public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.content_main); final CheckedTextView ctv = (CheckedTextView) findViewById(R.id.checkedTextView); ctv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (ctv.isChecked()) ctv.setChecked(false); else ctv.setChecked(true); } }); } }
...................................................................................................................................................................
try this...........
0 comments