In this Example you can see how to use Custom Listview with Seekbar ,TextView and Button in android ListView. Below is code for Activity which have ListView . public class SeekBarExampleActivity extends ListActivity implements OnClickListener, OnTouchListener, OnSeekBarChangeListener { /** Called when the activity is first created. */ ListView mListView; public static final int TOTAL_ITEM = 25; ImageView mImageView; ArrayListmSeekbarValue; ImageButton mImageButton; ListAdapter mListAdapter; TextView mTempTextview; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mListView = getListView(); mSeekbarValue = new ArrayList (TOTAL_ITEM); for(int i=0;i adapter, View view, int position, long lon) { } }; @Override public boolean onTouch(View v, MotionEvent event) { Log.v("Log_tag", "LinearView is Click"); /*LinearLayout mLinearlayout = (LinearLayout) v; if (mLinearlayout.getChildCount() > 0) { LinearLayout mtopLinearlayout = (LinearLayout) mLinearlayout .getChildAt(0); mTempTextview = (TextView) mtopLinearlayout.getChildAt(0); Log.v("Log_tag", "Tecview chnage"); }*/ return false; } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { int position = seekBar.getId(); LinearLayout mLinearlayout=(LinearLayout) seekBar.getParent(); if (mLinearlayout.getChildCount() > 0) { LinearLayout mtopLinearlayout = (LinearLayout) mLinearlayout .getChildAt(0); mTempTextview = (TextView) mtopLinearlayout.getChildAt(0); Log.v("Log_tag", "Tecview chnage"); } //mSeekbarValue.add(position, progress); mSeekbarValue.set(position, progress); updateTextview(progress); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } public void updateTextview(int paramValue) { if (mTempTextview != null) { mTempTextview.setText(String.valueOf(paramValue)); } } } Here is My Row xml used for Custom ListView: list_row_view.xml: main.xml
Blog is all about android developing and Android Mobile. #androidev #android #developer
Friday, 4 May 2012
Android Custom ListView with Seekbar ,TextView and Button
Subscribe to:
Posts (Atom)