I'm trying to add a button in a list View, I searched a lot on google but nothing was good enough for me.
Here's my code: I have 2 classes :
Menu.java
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
public class Menu extends ListActivity implements OnItemClickListener {
String[] listaMeniu = { "1", "2", "3"};
Button butonNota;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ListAdapter(this, listaMeniu));
ListView listView = getListView();
listView.setOnItemClickListener (this);
Button btnLoadMore = new Button(this);
btnLoadMore.setText("show me");
}
}
Menu.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:padding="5dp">
<ImageView
android:id="#+id/1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:src="#drawable/1" />
<TextView
android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize = "30dp"
android:text="1" />
</LinearLayout>
ListAdapter.java
package com.example.a;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class ListAdapter extends ArrayAdapter {
private Context context;
private String[] values;
public ListAdapter(Context context, String[] values) {
// TODO Auto-generated constructor stub
super (context, R.layout.menu, values);
this.context = context;
this.values = values;
}
}
I already made the list view, but I don't know how to add the button above the list. I tried to add it in menu.xml but it's shows up a button for every item in the list. Hope you guys understand what I want.
Thank you!
The best way is to create your custom adapter. For example :
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Button;
public class MySimpleArrayAdapter extends ArrayAdapter<String> {
private final Context context;
private final String[] values;
public MySimpleArrayAdapter(Context context, String[] values) {
super(context, R.layout.rowlayout, values);
this.context = context;
this.values = values;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.rowlayout, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.label);
Button buttonView = (Button) rowView.findViewById(R.id.button);
buttonView.setText(values[position]);
return rowView;
}
}
And here is the xml from "rowlayout.xml". You have to put the layout file in the res/layout project folder.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="#+id/button"
android:layout_width="22px"
android:layout_height="22px"
android:layout_marginLeft="4px"
android:layout_marginRight="10px"
android:layout_marginTop="4px">
</Button>
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#+id/label"
android:textSize="20px" >
</TextView>
</LinearLayout>
And then just update your Menu.java
public class Menu extends ListActivity implements OnItemClickListener {
String[] listaMeniu = { "1", "2", "3"};
Button butonNota;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new MySimpleArrayAdapter(this, listaMeniu));
...
}
}
You need to override method getView in your adapter to return Button.
It appears that you want your 10th item in the list to be a button.
That means that when you overwrite your ArrayAdapter class, you need to modify GetView() so it returns the button instead of a picture. Create two different layout XML files, rowlayout_picture.xml and rowlayout_button.xml, and then:
public View getView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = null;
if (position < 10)
rowView = inflater.inflate(R.layout.rowlayout_picture, parent, false);
else
rowView = inflater.inflate(R.layout.rowlayout_button, parent, false);
return rowView;
}
Related
I am a newbie in Android, so I am really sorry if the error that you will encounter is a blunder. I tried making a Custom ListView (An ImageView and a TextView in each row) by using custom_row.xml as the layout file and CustomAdapter.java as the customized adapter.
I do not understand why this application crashes every time I run the same. The exception (As shown in Android Monitor) is caused at this very line in the CustomAdapter.java file.
View customView = myInflater.inflate(R.layout.custom_row, parent, false);
I am attaching all of the Java and Layout codes for the reference. Thanks.
CustomAdapter.java
package com.abhinavankur.listexample;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ArrayAdapter;
class CustomAdapter extends ArrayAdapter<String> {
CustomAdapter(Context context, String[] teams) {
super(context,R.layout.custom_row,teams);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater myInflater = LayoutInflater.from(getContext());
View customView = myInflater.inflate(R.layout.custom_row, parent, false);
String singleTeam = getItem(position);
TextView myText = (TextView) customView.findViewById(R.id.myText);
ImageView myImage= (ImageView) customView.findViewById(R.id.myImage);
myText.setText(singleTeam);
myImage.setImageResource(R.drawable.mine);
return customView;
}
}
custom_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:id="#+id/myImage"
android:src="#drawable/mine"
android:layout_margin="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/myText"
android:layout_margin="5dp" />
</LinearLayout>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.abhinavankur.listexample.MainActivity">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/myListView">
</ListView>
</RelativeLayout>
MainActivity.java
package com.abhinavankur.listexample;
import android.os.Bundle;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity
{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String teams[] = {"Real Madrid","Manchester United","Barcelona","Chelsea","Bayern Munich","PSG","Borussia Dortmund","Liverpool","Arsenal","Valencia","Villareal","Leicester City","AS Roma"};
ListAdapter myAdapter = new CustomAdapter(this, teams);
ListView myList = (ListView) findViewById(R.id.myListView);
myList.setAdapter(myAdapter);
Toast.makeText(this,"List Shown",Toast.LENGTH_LONG).show();
myList.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String team = String.valueOf(parent.getItemAtPosition(position));
Toast.makeText(MainActivity.this,team,Toast.LENGTH_SHORT).show();
}
}
);
}
}
Change your CustomAdapter as below. You were inflating the layout in a wrong way.
class CustomAdapter extends ArrayAdapter<String> {
Context context;
CustomAdapter(Context context, String[] teams) {
super(context,R.layout.custom_row,teams);
this.context = context
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.custom_row, null);
}
....
....
}
I have an EditText inside ListView and I want to enter some integer values in all the EditTexts. I have one Button outside the ListView onClicking. From this button I want to get the data from all the EditText from ListView and save in array to show in toast. Also my EditText id is same for all the EditText. Can any buddy give so sample code so I can proceed to next step. Thanks in advance.
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="match_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/listGejalaPilih"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp" >
</ListView>
<Button
android:id="#+id/btnDiagnosis"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Diagnosis Penyakit" >
</Button>
</LinearLayout>
Item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textGejalaPilih"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_alignParentLeft="true" />
<EditText
android:id="#+id/editPersenYakin"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:inputType="number"
android:maxLength="3"
android:layout_alignParentRight="true" >
</EditText>
</RelativeLayout>
Main.java
package id.app.pakarsawit;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
public class DetailDiagnosis extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String[] pilihan = {"pilihan 1","pilihan 2","pilihan 3", "pilihan 4"};
ListView listView = (ListView)findViewById(R.id.listGejalaPilih);
Button btn = (Button)findViewById(R.id.btnDiagnosis);
ArrayAdapter<String> adapterPilih = new LVAdapterDetailDiagnosis(this, pilihan);
listView.setAdapter(adapterPilih);
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
}
});
}
}
LVAdapterDetailDiagnosis.java
package id.app.pakarsawit;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class LVAdapterDetailDiagnosis extends ArrayAdapter<String> {
private final Context context;
private final String[] values;
public LVAdapterDetailDiagnosis(Context context, String[] values) {
super(context, R.layout.item);
this.context = context;
this.values = values;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.item, parent, false);
TextView textView = (TextView)rowView.findViewById(R.id.textGejalaPilih);
textView.setText(values[position]);
return rowView;
}
}
try this:
for (int a = 0; a < listGejalaPilih.getCount(); a++) {
EditText et = (EditText) listGejalaPilih.getChildAt(a).findViewById(R.id.editPersenYakin);
arraylist.add(et.getText().toString());
}
Or if you want Array
String string[] = new String[listGejalaPilih.getCount()];
for (int a = 0; a < listGejalaPilih.getCount(); a++) {
EditText et = (EditText) listGejalaPilih.getChildAt(a).findViewById(R.id.editPersenYakin);
string[a] = et.getText().toString();
}
I meet a problem developing an android project.
Using adapter, I place many items in a ListView, and there is an ImageButton in each item. Now I want to set a click listener for these ImageButtons. What should I do?
This achieves your desired result. Its functionality is the button itself has a click response different from the container, which also has a response.
MainActivity.java
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list);
ListView lv = (ListView) findViewById( R.id.list );
lv.setOnItemClickListener(
new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0,
android.view.View arg1, int arg2, long arg3) {
Toast.makeText( MainActivity.this,
"List item clicked",
Toast.LENGTH_SHORT).show();
}
});
ArrayList<String> items = new ArrayList<String>();
items.add( "item1");
items.add( "item2");
items.add( "item3");
ListAdapter adapter = new ListAdapter( this, items);
lv.setAdapter( adapter );
}
}
ListAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.BaseAdapter;
import android.widget.Toast;
import java.util.List;
public class ListAdapter extends BaseAdapter {
public ListAdapter(Context context,
List<String> items ) {
inflater = LayoutInflater.from( context );
this.context = context;
this.items = items;
}
public int getCount() {
return items.size();
}
public Object getItem(int position) {
return items.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
String item = items.get(position);
View v = null;
if( convertView != null )
v = convertView;
else
v = inflater.inflate( R.layout.item, parent, false);
TextView itemTV = (TextView)v.findViewById( R.id.item);
itemTV.setText( item );
ImageButton button =
(ImageButton)v.findViewById( R.id.button);
button.setOnClickListener(
new OnClickListener() {
public void onClick(View v) {
Toast.makeText( context,
"ImageButton clicked",
Toast.LENGTH_SHORT).show();
}
});
return v;
}
private Context context;
private List<String> items;
private LayoutInflater inflater;
}
item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants" >
<TextView
android:id="#+id/item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textSize="28sp" />
<ImageButton
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#android:color/transparent"
android:src="#drawable/emo_im_cool" />
</RelativeLayout>
list.xml
<?xml version="1.0" encoding="utf-8" ?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/list" />
Try it out and hopefully you can see what's going on to learn what you need
I have a custom ArrayAdapter which contains a text and an image, but somehow the items don't show in the list.
This is my custom adapter:
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class DrawerArrayAdapter extends ArrayAdapter<String> {
private final Context context;
private final String[] entries;
private final Integer[] imageIds;
public DrawerArrayAdapter(Context context, String[] entries, Integer[] imageIds) {
super(context, R.layout.drawer_list_item, entries);
this.context = context;
this.entries = entries;
this.imageIds = imageIds;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.drawer_list_item, parent, false);
TextView entryView = (TextView) rowView.findViewById(R.id.drawer_list_entry);
ImageView iconView = (ImageView) rowView.findViewById(R.id.drawer_list_icon);
entryView.setText(entries[position]);
iconView.setImageResource(imageIds[position]);
return rowView;
}
}
And this is the Fragment:
import android.app.ListFragment;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class DrawerFragment extends ListFragment {
private String[] drawerListEntries;
private DrawerLayout drawerLayout;
private Integer[] drawerListIcons;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
drawerListIcons = new Integer[] {R.drawable.ic_action_user,R.drawable.ic_action_user,R.drawable.ic_action_user,R.drawable.ic_action_user};
drawerListEntries = getResources().getStringArray(R.array.drawer_items);
setListAdapter(new DrawerArrayAdapter(getActivity(), drawerListEntries, drawerListIcons));
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.drawer_fragment, container, false);
}
#Override
public void onStart() {
super.onStart();
drawerLayout = (DrawerLayout) getActivity().findViewById(R.id.drawer_layout);
}
#Override
public void onListItemClick(ListView l, View v, int position, long id) {
Toast.makeText(getActivity(),
getListView().getItemAtPosition(position).toString(),
Toast.LENGTH_LONG).show();
}
#Override
public void onPrepareOptionsMenu(Menu menu) {
//boolean drawerOpen = drawerLayout.isDrawerOpen(drawerList);
//menu.findItem(R.id.action_user).setVisible(!drawerOpen);
super.onPrepareOptionsMenu(menu);
}
}
and this is my drawer_list_item.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="70dp"
android:padding="5dp"
android:orientation="vertical" >
<TextView
android:id="#+id/drawer_list_entry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="12dp"
android:paddingLeft="20dp"
android:paddingBottom="20dp"
android:paddingTop="20dp"
android:textSize="24sp"
android:textColor="#color/light_blue"
android:fontFamily="sans-serif-light" >
</TextView>
<ImageView
android:id="#+id/drawer_list_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/drawer_icon">
</ImageView>
</LinearLayout>
I should probably mention that when I just use a normal ArrayAdapter with just text, it works perfectly. Anyone seeing the problem?
You really don't want to inflate new views for every row in your custom adapter's getView() ignoring the provided convertView. ListViews don't use 1000 separate views when you have 1000 rows in the adapter, views get recycled.
So I would simply call:
View view = super.getView(position, convertView, parent);
and then use view.findViewById() to set the data on your individual sub-views before returning the view that the ArrayAdapter returned. The ArrayAdapter already takes care of re-using recycled views.
Note that ArrayAdapter already sets the TextView itself, so you only need to set the ImageView, but for that the ArrayAdapter will need to know the id of your TextView, so use the constructor:
super(context, R.layout.drawer_list_item, R.id.drawer_list_entry, entries);
Because views are recycled make sure to always set the ImageView source. If a particular row has no image you need to clear it rather than do nothing.
EDIT: Another problem was related to the row layout. The vertical margin and padding was too much for the limited vertical row height of 70dp.
EDIT: Here an example of the adapter.
public class DrawerArrayAdapter extends ArrayAdapter<String> {
private final Integer[] mImageIds;
public DrawerArrayAdapter(Context context, String[] entries, Integer[] imageIds) {
super(context, R.layout.drawer_list_item, R.id.drawer_list_entry, entries);
mImageIds = imageIds;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = super.getView(position, convertView, parent);
((ImageView)rowView.findViewById(R.id.drawer_list_icon)).setImageResource(mImageIds[position]);
return rowView;
}
}
Some suggestions here.
1) Extend BaseAdapter instead of ArrayAdapter.
2) implement getCount method of base adapter and return list.size as return value(integer). here list can be your arrays length.
I use a ListView with a custom adapter to build a list with ckeckboxes. Now I dont know how i can fetch the "ID" from the selected box.
The xml file for the items look like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<TextView android:id="#+id/class_open"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
<CheckBox
android:id="#+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:onClick="clickHandler" />
<TextView
android:id="#+id/medi_name"
android:text="Test"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/checkbox" />
</RelativeLayout>
I need the value from: "class_open"
this is my activity:
package de.bodprod.dkr;
import java.util.ArrayList;
import java.util.HashMap;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class MediNotmediUserListNew extends Activity{
LayoutInflater inflater;
ArrayList<HashMap<String, Object>> medi_notmedi_items;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.medi_notmedi_user_list_new);
ListView mediListCheck = (ListView) findViewById(android.R.id.list);
inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
medi_notmedi_items = new ArrayList<HashMap<String,Object>>();
SystemDatabaseHandler db = new SystemDatabaseHandler(getApplicationContext());
medi_notmedi_items = db.getAllNotmedis();
final CustomAdapter adapter = new CustomAdapter(this, R.layout.medi_notmedi_user_list_new, medi_notmedi_items);
mediListCheck.setAdapter(adapter);
}
public void clickHandler(View view) {
}
private class CustomAdapter extends ArrayAdapter<HashMap<String, Object>>{
public CustomAdapter(Context context, int textViewResourceId, ArrayList<HashMap<String, Object>> Strings) {
super(context, textViewResourceId, Strings);
}
private class ViewHolder{
TextView class_open, title;
}
ViewHolder viewHolder;
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView==null){
convertView=inflater.inflate(R.layout.medi_notmedi_user_list_new_item, null);
viewHolder=new ViewHolder();
viewHolder.class_open=(TextView) convertView.findViewById(R.id.class_open);
viewHolder.title=(TextView) convertView.findViewById(R.id.medi_name);
convertView.setTag(viewHolder);
}else{
viewHolder=(ViewHolder) convertView.getTag();
}
viewHolder.class_open.setText(medi_notmedi_items.get(position).get("sql_id").toString());
viewHolder.title.setText(medi_notmedi_items.get(position).get("wirk").toString());
return convertView;
}
}
}
How I can get the value from the class_open field in the clickHandler?
Is it possible to assign the value directly to the checkbox and request it?
Is it possible to request the value from the class_open field?
Please excuse my bad english
Markus