I am making an app which has a main recycler view and an internal recycler view that goes inside the main recycler view. The problem is that the list of elements is not displayed inside the recycler view, I have tried several things that you mention in this forum but I have not had good results. I read about nestedscrollview but it has not worked either, the last thing I tried was what I leave you in the code. This works but it is not efficient since in the emulator there are times when paste the scroll view (so the data is displayed "in jerks"
recycler
public class adapterArguments extends RecyclerView.Adapter<adapterArguments.ViewHolder> {
private List<ListArguments> data;
private LayoutInflater inflater;
private Context context;
public String position_selected;
public static String argument;
public adapterArguments listArguments;
RecyclerView recyclerView_arguments;
public adapterArguments(List<ListArguments> itemList, Context context) {
this.data = itemList;
this.inflater = LayoutInflater.from(context);
this.context = context;
}
#NonNull
#Override
public ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = inflater.inflate(R.layout.compontents_arguments_recyclerview,null);
recyclerView_arguments= view.findViewById(R.id.recycler_argument);
return new adapterArguments.ViewHolder(view);
}
#Override
public void onBindViewHolder(#NonNull ViewHolder holder, int position) {
ConexionSQliteHelper conn=new ConexionSQliteHelper(context,"db_testwuad_7",null,31);
holder.arguments.setText(data.get(position).getArguments());
holder.name_user.setText(data.get(position).getName_user());
holder.date.setText(data.get(position).getDate_arguments());
holder.position.setText(data.get(position).getPosition());
int id_argument_selected = data.get(position).getId();
position_selected = holder.position.getText().toString();
holder.list_contrarguments = conn.getContrarguments(id_argument_selected);
holder.recyclerView_contrarguments.setLayoutManager(new LinearLayoutManager(context));
holder.recyclerView_contrarguments.setHasFixedSize(true);
holder.listContrarguments = new adapterContrarguments(holder.list_contrarguments,context);
holder.recyclerView_contrarguments.setAdapter(holder.listContrarguments);
final int[] checkedItem = {-1};
if(position_selected.equals("A favor")){
holder.position.setBackgroundColor(Color.parseColor("#073FD7"));
}
else{
holder.position.setBackgroundColor(Color.parseColor("#FC0C1E"));
}
holder.addContrarguments.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(v.getContext());
alertDialog.setTitle("Añadir un Contrargumento");
alertDialog.setMessage("¿Quieres añadir un contrargumento a este texto?");
alertDialog.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
argument = holder.arguments.getText().toString();
contrargument fragment = new contrargument();
Bundle args = new Bundle();
args.putString("argument", argument);
args.putInt("id",id_argument_selected);
fragment.setArguments(args);
FragmentManager fragmentManager;
FragmentTransaction fragmentTransaction;
fragmentManager = ((AppCompatActivity)context).getSupportFragmentManager();
fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.container, fragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}
});
alertDialog.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
AlertDialog customAlertDialog = alertDialog.create();
customAlertDialog.show();
}
});
holder.deleteDiscuss.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(v.getContext());
alertDialog.setTitle("Eliminar argumento");
alertDialog.setMessage("¿Quieres eliminar un argumento a este texto?");
alertDialog.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
boolean user_create_debate = conn.verifyCreatorDebate(holder.name_user.getText().toString());
if(user_create_debate){
conn.deleteArgument(id_argument_selected);
data = conn.getArguments(id_argument_selected);
listArguments = new adapterArguments(data,context);
notifyDataSetChanged();
}
else{
Toast.makeText(context, "No puede eliminar el argumento,ya que no es el creador del texto", Toast.LENGTH_SHORT).show();
}
opinionUserOnPostDebate fragment = new opinionUserOnPostDebate();
FragmentManager fragmentManager;
FragmentTransaction fragmentTransaction;
fragmentManager = ((AppCompatActivity)context).getSupportFragmentManager();
fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.detach(fragment).attach(fragment).commit();
}
});
alertDialog.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
AlertDialog customAlertDialog = alertDialog.create();
customAlertDialog.show();
}
});
holder.changePosition.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
alertDialog.setTitle("Cambio de postura");
final String[] listItems = new String[]{"Cambie de opinión","Me equivoque de botón","Otro"};
alertDialog.setSingleChoiceItems(listItems, checkedItem[0], new DialogInterface.OnClickListener() {
#SuppressLint("SetTextI18n")
#Override
public void onClick(DialogInterface dialog, int which) {
checkedItem[0] = which;
}
});
alertDialog.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
if(position_selected.equals("A favor")){
//conn.changePosition(id_argument_selected,"En contra");
}
else{
//conn.changePosition(id_argument_selected,"A favor");
}
}
});
alertDialog.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog customAlertDialog = alertDialog.create();
customAlertDialog.show();
}
});
holder.Report.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
alertDialog.setTitle("Reportar post");
final String[] listItems = new String[]{"Opinión contiene lenguaje ofensivo","Opinión contiene información personal","Otro"};
alertDialog.setSingleChoiceItems(listItems, checkedItem[0], new DialogInterface.OnClickListener() {
#SuppressLint("SetTextI18n")
#Override
public void onClick(DialogInterface dialog, int which) {
checkedItem[0] = which;
}
});
alertDialog.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
if(position_selected.equals("A favor")){
//conn.changePosition(id_argument_selected,"En contra");
}
else{
//conn.changePosition(id_argument_selected,"A favor");
}
}
});
alertDialog.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog customAlertDialog = alertDialog.create();
customAlertDialog.show();
}
});
}
#Override
public int getItemCount() {
return data.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView arguments,name_user,date,position;
ImageButton addContrarguments,deleteDiscuss,addFriend,changePosition,Report;
List<ListContrarguments> list_contrarguments;
RecyclerView recyclerView_contrarguments;
public adapterContrarguments listContrarguments;
public ViewHolder(#NonNull View itemView) {
super(itemView);
arguments = itemView.findViewById(R.id.arguments_posted);
name_user = itemView.findViewById(R.id.name_arguments);
date = itemView.findViewById(R.id.date_arguments);
position = itemView.findViewById(R.id.position);
addContrarguments = itemView.findViewById(R.id.comments);
deleteDiscuss = itemView.findViewById(R.id.delete);
changePosition = itemView.findViewById(R.id.change_position);
addFriend = itemView.findViewById(R.id.add_friend);
Report = itemView.findViewById(R.id.report_argument);
recyclerView_contrarguments = itemView.findViewById(R.id.recycler_contrargument);
recyclerView_contrarguments.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
#Override
public boolean onInterceptTouchEvent(#NonNull RecyclerView rv, #NonNull MotionEvent e) {
int action = e.getAction();
switch (action) {
case MotionEvent.ACTION_MOVE:
rv.getParent().requestDisallowInterceptTouchEvent(true);
break;
}
return false;
}
#Override
public void onTouchEvent(#NonNull RecyclerView rv, #NonNull MotionEvent e) {
}
#Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
}
}
}
layout.compontents_arguments_recyclerview.xml:external recyclerview
<LinearLayout 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:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:id="#+id/position"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="40dp"
android:textStyle="bold"
android:textSize="25dp"
android:background="#0AA842">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/image_person_contrarguments"
android:layout_width="100dp"
android:layout_height="80dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="15dp"
android:layout_marginRight="5dp">
</ImageView>
<TextView
android:id="#+id/name_arguments"
android:layout_width="145dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="15dp"
android:textSize="14sp"
>
</TextView>
<TextView
android:id="#+id/date_arguments"
android:layout_width="145dp"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
>
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:id="#+id/arguments_posted"
android:layout_width="match_parent"
android:layout_height="140dp"
>
</TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
android:background="#FEFEFE"
>
<ImageButton
android:id="#+id/comments"
android:layout_width="60dp"
android:layout_height="match_parent"
android:src="#drawable/add_comments"
android:background="#FEFEFE"
android:layout_marginLeft="50dp"
>
</ImageButton>
<ImageButton
android:id="#+id/delete"
android:layout_width="60dp"
android:layout_height="match_parent"
android:src="#drawable/delete"
android:background="#FEFEFE"
>
</ImageButton>
<ImageButton
android:id="#+id/change_position"
android:layout_width="60dp"
android:layout_height="match_parent"
android:src="#drawable/change_opinion"
android:background="#FEFEFE"
>
</ImageButton>
<ImageButton
android:id="#+id/add_friend"
android:layout_width="60dp"
android:layout_height="match_parent"
android:src="#drawable/add_friend"
android:background="#FEFEFE"
>
</ImageButton>
<ImageButton
android:id="#+id/report_argument"
android:layout_width="60dp"
android:layout_height="match_parent"
android:src="#drawable/display_report"
android:background="#FEFEFE"
>
</ImageButton>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#A4A1A1"
>
</View>
<include
layout="#layout/recyclerview_contrarguments"
android:layout_width="match_parent"
android:layout_height="281dp">
</include>
</LinearLayout>
</LinearLayout>
</LinearLayout>
recyclerviee_contrarguments:intern recyclerview
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.core.widget.NestedScrollView
android:id="#+id/scroll_discuss"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="MissingConstraints">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_contrargument"
android:layout_width="442dp"
android:layout_height="match_parent"></androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
Check to see if this helps.
https://stackoverflow.com/a/37338715/19652887
Also, can u try changing the parent layout of your recycler view from linear layout to constraint layout and use recycler view's width as 0dp?
That's what fixed my problem
Hope this helps.
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/device_toolbar">
<com.google.android.material.card.MaterialCardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/_3sdp"
android:layout_marginBottom="#dimen/_50sdp"
android:elevation="#dimen/_5sdp"
app:cardCornerRadius="#dimen/_20sdp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/_10sdp"
android:paddingVertical="#dimen/_10sdp"
android:paddingStart="#dimen/_5sdp"
android:paddingEnd="#dimen/_5sdp">
.......(other views).......
<com.google.android.material.button.MaterialButton
android:id="#+id/grant_storage_permission"
style="#style/Widget.Material3.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_10sdp"
android:text="Grant Permission"
android:textColor="#color/color_on_primary_light"
android:textSize="#dimen/_11ssp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/storage_text"
app:strokeColor="#color/color_secondary_variant_light" />
<androidx.constraintlayout.widget.Group
android:id="#+id/group_storage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
app:constraint_referenced_ids="grant_storage_permission, storage_text" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/storage_rec_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/used_ram_text"
android:layout_marginTop="#dimen/_10sdp" />
<LinearLayout
android:id="#+id/storage_group_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="#dimen/_20sdp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/grant_storage_permission" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.core.widget.NestedScrollView>
Related
I'm trying to pass information from my second activity to my first activity. In my second Activity contains a list view of images of provinces in Canada. Each item in the list contains 3 properties (Province Name, Capital of the Province, Image id for the actual flag of the province). When the user selects an item from the listView it should direct them to the first Activity and pass the intent information from the second Activity to the first Activity. The information that will be passed are the name of the province and the capital of the province. I feel like I'm doing it correctly and my app currently has no issue in terms of bugs or crashes but I can't seem to figure out why the information is not being passed from activity 2 to activity 1. It just passes nothing. Thanks to those all in advance that help me out!
Main Activity.Java
TextView provinceTxt, capitalTxt;
String provinceString, capitalString;
ArrayList<Province> provinces;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
provinceTxt = findViewById(R.id.txtProvince);
capitalTxt = findViewById(R.id.txtCapital);
display();
}
public void selectProvince(View view) {
showAlertDialog();
}
public void showAlertDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Would You Like to Open the Second Activity?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(MainActivity.this, Second_Activity.class);
startActivity(intent);
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
public void display(){
Intent intent = getIntent();
provinceString = intent.getStringExtra("name");
provinceTxt.setText(provinceString);
capitalString = intent.getStringExtra("capital");
capitalTxt.setText(capitalString);
}
}
Second Activity.Java
List<Province> provinces;
ListView listView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second_);
provinces = ProvincesData.getList();
listView = findViewById(R.id.listView);
CustomAdapter adapter = new CustomAdapter(Second_Activity.this, R.layout.list_view_row, provinces);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
Province province = (Province) listView.getItemAtPosition(position);
Intent intent = new Intent();
intent.putExtra("name", province.getName());
intent.putExtra("capital", province.getCapital());
finish();
}
});
}
}
Province.Java
public class Province {
String name;
String capital;
public Province(String name, String capital, int armID) {
this.name = name;
this.capital = capital;
this.armID = armID;
}
int armID;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCapital() {
return capital;
}
public void setCapital(String capital) {
this.capital = capital;
}
public int getArmID() {
return armID;
}
public void setArmID(int armID) {
this.armID = armID;
}
}
ProvincesData.Java
public static List<Province> getList() {
List<Province> provinces = new ArrayList<Province>();
Province province1 = new Province("Alberta","Edmonton", R.drawable.alberta);
provinces.add(province1);
Province province2 = new Province("British Columbia","Victoria", R.drawable.british_columbia);
provinces.add(province2);
Province province3 = new Province("Manitoba","Winnipeg", R.drawable.manitoba);
provinces.add(province3);
Province province4 = new Province("New Brunswick","Fredericton", R.drawable.new_brunswick);
provinces.add(province4);
Province province5 = new Province("Newfoundland and Labrador","St. John's", R.drawable.newfoundland_and_labrador);
provinces.add(province5);
Province province6 = new Province("Nova Scotia","Halifax", R.drawable.nova_scotia);
provinces.add(province6);
Province province7 = new Province("Ontario","Toronto", R.drawable.ontario);
provinces.add(province7);
Province province8 = new Province("Quebec","Quebec City", R.drawable.quebec);
provinces.add(province8);
Province province9 = new Province("Saskatchewan","Regina", R.drawable.saskatchewan);
provinces.add(province9);
Province province10 = new Province("Prince Edward ","Charlottetown", R.drawable.prince_edward_island);
provinces.add(province10);
return provinces;
}
}
CustomAdapter.Java
public class CustomAdapter extends ArrayAdapter {
static class ViewHolder{
TextView provinceTv;
TextView cityTv;
ImageView armID;
}
List<Province> provinces;
public CustomAdapter(#NonNull Context context, int resource, #NonNull List objects) {
super(context, resource, objects);
provinces = objects;
}
#NonNull
#Override
public View getView(int position, #Nullable View convertView, #NonNull ViewGroup parent) {
ViewHolder holder;
View view = convertView;
if(view == null){
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.list_view_row , null);
holder = new ViewHolder();
holder.provinceTv = view.findViewById(R.id.txtProvinceRow);
holder.cityTv = view.findViewById(R.id.txtCapitalRow);
holder.armID = view.findViewById(R.id.imageView);
view.setTag(holder);
}
holder = (ViewHolder)view.getTag();
holder.provinceTv.setText(provinces.get(position).getName());
holder.cityTv.setText(provinces.get(position).getCapital());
holder.armID.setBackgroundResource(provinces.get(position).getArmID());
return view;
}
}
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:text="Selected Province Info"
android:textAppearance="#style/TextAppearance.AppCompat.Large"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginHorizontal="25dp"
android:orientation="horizontal">
<TextView
android:id="#+id/txtProvinceTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Province Name"
android:textAppearance="#style/TextAppearance.AppCompat.Large"
android:textStyle="bold" />
<TextView
android:id="#+id/txtProvince"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="text"
android:textAppearance="#style/TextAppearance.AppCompat.Large"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginHorizontal="25dp"
android:orientation="horizontal">
<TextView
android:id="#+id/txtCapitalTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Capital City"
android:textAppearance="#style/TextAppearance.AppCompat.Large"
android:textStyle="bold"/>
<TextView
android:id="#+id/txtCapital"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="text"
android:textAppearance="#style/TextAppearance.AppCompat.Large" />
</LinearLayout>
<Button
android:id="#+id/btnSelect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginHorizontal="30dp"
android:text="Select Province"
android:onClick="selectProvince"
android:textAppearance="#style/TextAppearance.AppCompat.Large"
android:textStyle="bold"/>
</LinearLayout>
Activity_second.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".Second_Activity">
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
list_view_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginHorizontal="10dp"
android:layout_weight="1"
tools:srcCompat="#tools:sample/avatars" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_weight="2"
android:layout_marginHorizontal="10dp"
android:orientation="vertical">
<TextView
android:id="#+id/txtProvinceRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="#style/TextAppearance.AppCompat.Large"
android:textStyle="bold"
android:text="" />
<TextView
android:id="#+id/txtCapitalRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"
android:text="" />
</LinearLayout>
</LinearLayout>
You forget to start the intent
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
Province province = (Province) listView.getItemAtPosition(position);
Intent intent = new Intent(this.Second_Activity.class, MainActivity);
intent.putExtra("name", province.getName());
intent.putExtra("capital", province.getCapital());
startActivity(intent);
finish();
}
});
receive the intent
public void display(){
Bundle extras = intent.getExtras();
if(extras != null){
String provinceString = extras.getString("name");
provinceTxt.setText(provinceString);
String capitalString = extras.getString("capital");
capitalTxt.setText(capitalString);
}
}
for more details refer this
you can use Activity.startActivityForResult(Intent intent, int requestCode)to start Second Activity and use Activity.onActivityResult(int requestCode, int resultCode, Intent data) to receive data that from Second Activityin MainActivity
My RecyclerView doesn't show any value in alert dialog. I am confused and don't know where should I looking for a problem in my code. I hope some of you guys met with same issue.
This is activity where I am calling my RecycleView andl AlertDialog.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pondeljak = (Button) findViewById(R.id.buttonPonedeljak);
utorak = (Button) findViewById(R.id.buttonUtorak);
sreda = (Button) findViewById(R.id.buttonSreda);
cetvrtak = (Button) findViewById(R.id.buttonCetvrtak);
petak = (Button) findViewById(R.id.buttonPetak);
db = new DataDays(this);
View view = getLayoutInflater().inflate(R.layout.casovi,null);
alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setView(view);
alertDialog = alertDialogBuilder.create();
recyclerView = (RecyclerView) view.findViewById(R.id.recycleCasoviID);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
casoviList = new ArrayList<>();
casoviItems = new ArrayList<>();
// for (Casovi c: casoviList){
Casovi casovi = new Casovi();
//casovi.setId(0);
casovi.setDan("asas");
casovi.setRedniBrCasa("ssss");
casovi.setNzaivCasa("ssddff");
casoviItems.add(casovi);
recycleViewAdapter = new RecycleViewAdapter(this, casoviItems);
recyclerView.setAdapter(recycleViewAdapter);
recycleViewAdapter.notifyDataSetChanged();
pondeljak.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (db.casoviCountPondeljak() == 0){
Intent intent = new Intent(MainActivity.this, Unos_casova.class);
intent.putExtra("Dan", "Pondeljak");
startActivity(intent);
}else {
alertDialog.show();
}
This is RecycleView class. I am not sure, maybe here is some problem?
public class RecycleViewAdapter extends RecyclerView.Adapter<RecycleViewAdapter.ViewHolder> {
private Context context;
private List<Casovi> casoviItems;
public RecycleViewAdapter(Context context, List<Casovi> casoviItems) {
this.context = context;
this.casoviItems = casoviItems;
}
#Override
public RecycleViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.prikaz_casova, parent,false);
return new ViewHolder(view, context);
}
#Override
public void onBindViewHolder( RecycleViewAdapter.ViewHolder holder, int position) {
Casovi casovi = new Casovi();
holder.redniBrCasPrikaz.setText(casovi.getRedniBrCasa());
holder.nazivCasPrikaz.setText(casovi.getRedniBrCasa());
}
#Override
public int getItemCount() {
return casoviItems.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView redniBrCasPrikaz;
public TextView nazivCasPrikaz;
public Button delteBtn;
public Button editBtn;
public CardView cardView;
public ViewHolder(View view, Context ctx) {
super(view);
context = ctx;
redniBrCasPrikaz = (TextView) view.findViewById(R.id.rednibrojCasaID);
nazivCasPrikaz = (TextView) view.findViewById(R.id.nazivcasaID);
delteBtn = (Button) view.findViewById(R.id.obrisiCasBtnID);
editBtn = (Button) view.findViewById(R.id.izmeniCasBtnID);
cardView = (CardView) view.findViewById(R.id.carViewID);
}
}
Layout casovi. That RecycleView on witch prikaz casova should be attached.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycleCasoviID"
android:layout_width="match_parent"
android:layout_height="574dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.283" />
</android.support.constraint.ConstraintLayout>
Layout prikaz_casova. This layout should show values from db. In this exemple I've posted there is hadrdoced values tho be showen.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="#+id/carViewID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="133dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="470dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.471">
<RelativeLayout
android:id="#+id/relativniID"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/rednibrojCasaID"
android:layout_width="126dp"
android:layout_height="wrap_content"
android:text="redni broj casa"
android:textSize="14dp"
android:textStyle="italic"
/>
<TextView
android:id="#+id/nazivcasaID"
android:layout_width="338dp"
android:layout_height="105dp"
android:layout_below="#+id/rednibrojCasaID"
android:layout_marginTop="1dp"
android:text="Naziv casa"
android:textSize="24dp"
android:textStyle="bold" />
<Button
android:id="#+id/obrisiCasBtnID"
android:layout_width="40dp"
android:layout_height="37dp"
android:layout_below="#+id/rednibrojCasaID"
android:layout_toRightOf="#+id/nazivcasaID"
android:background="#drawable/delete" />
<Button
android:id="#+id/izmeniCasBtnID"
android:layout_width="40dp"
android:layout_height="37dp"
android:layout_below="#+id/obrisiCasBtnID"
android:layout_marginLeft="3dp"
android:layout_marginTop="15dp"
android:layout_toRightOf="#+id/nazivcasaID"
android:background="#drawable/edit" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
Here the error you made, in your RecyclerView Adapter class.
#Override
public void onBindViewHolder( RecycleViewAdapter.ViewHolder holder, int position) {
Casovi casovi = new Casovi();
It should be
Casovi casovi = casoviItems.get(position);
holder.redniBrCasPrikaz.setText(casovi.getRedniBrCasa());
holder.nazivCasPrikaz.setText(casovi.getRedniBrCasa());
}
You are all done
I'd need your help to do something in Android, in the following the use case.
I have created a custom dialog in Android, whose layout is:
dialog_threshold.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp">
<ImageView
android:src="#drawable/ic_media_route_on_03_dark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="center"
android:background="#FFFFBB33"
android:contentDescription="#string/set_target" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner_threshold" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/layout_threshold">
<TextView
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/targetSelected"
android:layout_weight="1" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/threshold_operator_spinner"
android:layout_weight="1" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text=""
android:ems="10"
android:id="#+id/threshold_val"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
And in the Activity, when I click on a specific button, I have something like this, to create the custom dialog:
setThreshold_button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
AlertDialog.Builder mBuilder = new AlertDialog.Builder(DiseaseActivity.this);
//Inflate the custom layout
View mView = getLayoutInflater().inflate(R.layout.dialog_threshold, null);
//Set title for dialog
mBuilder.setTitle("Set thresholds for your target");
//Define the spinner inside your custom layout
final Spinner mSpinner = (Spinner) mView.findViewById(R.id.spinner_threshold); //because it doesn't exist in the main layout, but only in the custom layout
//Define the ArrayAdapter
ArrayAdapter<String> adapter = new ArrayAdapter<String>(DiseaseActivity.this,
android.R.layout.simple_spinner_item,
getResources().getStringArray(R.array.threshold_choices));
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpinner.setAdapter(adapter);
if (!mSpinner.getSelectedItem().toString().equalsIgnoreCase("Choose a threshold option")) {
String ThresholdSelection = mSpinner.getSelectedItem().toString();
}
mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if ((dialog2 != null) && dialog2.isShowing() && !mSpinner.getSelectedItem().toString().equalsIgnoreCase("Choose a threshold option")) {
dialog2.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
} else {
dialog2.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
//Set the positive and negative button for the custom dialog
mBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
disease.setThreshold(mSpinner.getSelectedItem().toString());
if (!mSpinner.getSelectedItem().toString().equalsIgnoreCase("Choose a threshold option")) {
Toast.makeText(DiseaseActivity.this,
mSpinner.getSelectedItem().toString(),
Toast.LENGTH_SHORT)
.show();
setInterval_button.setEnabled(true);
}
}
});
mBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
mBuilder.setView(mView);
dialog2 = mBuilder.create();
dialog2.show();
dialog2.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
});
What I want to do now is to add dynamically other components (like EditText or TextView) to the above Dialog before is it shown.
How can I do it?
Thanks in advance!
just create your custom view >> find the parent(in which viewgroup you want to add) >>> and add it. eg:-
mView.addView(new TextView(ActivityContext),LayoutParamss);
mBuilder.setView(mView);
I'm trying to create a custom dialog for the settings of my application, the problem is, that the custom buttons, EditText & the spinner don't respond to user activity. I hope someone can help.
Here is my Code:
public class SettingsDialog extends DialogFragment {
private EditText editText;
private Spinner ipSpinner;
private MainActivity mainActivity;
private Settings settings;
private int selectedIP;
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.dialog_settings, null);
mainActivity = (MainActivity) getActivity();
settings = mainActivity.getSettings();
selectedIP = settings.getSelectedIP();
editText = (EditText) dialogView.findViewById(R.id.edit_text_ip);
ipSpinner = (Spinner) dialogView.findViewById(R.id.spinner_ip);
ImageButton imageButton = (ImageButton) dialogView.findViewById(R.id.image_button_save_ip);
imageButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String IP = editText.getText().toString();
settings.setIP(selectedIP, IP);
settings.settingsSave();
mainActivity.showToast("IP at " + Integer.toString(selectedIP) + " with value" + IP);
}
});
ipSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
selectedIP = position;
editText.setText(settings.getIP(selectedIP));
mainActivity.showToast(Integer.toString(position));
settings.settingsSave();
}
#Override
public void onNothingSelected(AdapterView<?> parentView) {
return;
}
});
builder.setView(inflater.inflate(R.layout.dialog_settings, null))
.setPositiveButton("Save", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int id) {
String IP = editText.getText().toString();
settings.setIP(selectedIP, IP);
settings.settingsSave();
mainActivity.showToast("IP at " + Integer.toString(selectedIP) + " with value" + IP);
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
SettingsDialog.this.getDialog().cancel();
}
});
return builder.create();
}
}
and my xml for the dialog:
<LinearLayout 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:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="IP-address"
android:textAllCaps="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Spinner
android:id="#+id/spinner_ip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="#array/spinner_ip_visual"
android:entryValues="#array/spinner_ip_values" />
<EditText
android:id="#+id/edit_text_ip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="8" />
<ImageButton
android:id="#+id/image_button_save_ip"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#null"
android:src="#drawable/ic_done_black_24dp"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="unit"
android:textAllCaps="true" />
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="#+id/button_unit_celsius"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Celsius"
android:textAllCaps="true" />
<RadioButton
android:id="#+id/button_unit_fahrenheit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fahrenheit"
android:textAllCaps="true" />
</RadioGroup>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onButtonClickGenerateRandomData"
android:text="Generate random data"
android:textAllCaps="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onButtonClickDropDatabase"
android:text="delete weatherdata"
android:textAllCaps="true" />
Thanks in advice
You are inflating dialogView and then you set listeners for the views that are in dialogView, however when you set the view for dialog builder, you inflate the new view.
This is wrong.
builder.setView(inflater.inflate(R.layout.dialog_settings, null))
This is correct
builder.setView(dialogView)
I've a class which extends Dialog in android.It shows custom dialog well.But i couldn't set icon & title for that dialog.How could i do that?
My code:
public class helpDialog extends Dialog implements OnClickListener {
Button okButton;
String Description;
TextView text;
public helpDialog(Context context, String desc) {
super(context);
Description=desc;
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
/** Design the dialog in main.xml file */
setContentView(R.layout.custom);
text=(TextView)findViewById(R.id.text);
text.setText(Description);
okButton = (Button) findViewById(R.id.submit);
okButton.setOnClickListener(this);
}
#Override
public void onClick(View v) {
/** When OK Button is clicked, dismiss the dialog */
if (v == okButton)
dismiss();
}
}
My custom.xml:
<TextView
android:id="#+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:textColor="#000000"
android:gravity="center"
android:text="Help alert for iDispatch"
android:textSize="18dp" />
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK"
android:textColor="#FFFFFF" />
USE THIS ONE
private AlertDialog AskOption()
{
AlertDialog myQuittingDialogBox =new AlertDialog.Builder(this)
//set message, title, and icon
.setTitle("Confirm Delete")
.setMessage("Do you want to Delete Employee "+listview_array[1]+" ?")
.setIcon(R.drawable.dialog_warning)
.setPositiveButton(resource.getString(R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton)
{
if(dh.selectEmployeeTypeById(EmpId).size()>0)
{
//CODE
}
dialog.dismiss();
}
})
.setNegativeButton(resource.getString(R.string.no), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})
.create();
return myQuittingDialogBox;
}
for custom dialog a small example layout this is my custom dialog
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".StaffTimeClock" >
<TextView android:id="#+id/img"
android:layout_width="fill_parent"
android:text="#string/selectjob"
android:gravity="center"
android:textSize="30dp"
android:textColor="#fff"
android:background="#203C56"
android:padding="10dp"
android:layout_height="wrap_content"/>
<ListView
android:id="#+id/list"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:cacheColorHint="#222000" />
<View
android:layout_width="fill_parent"
android:layout_height="3dp"
android:background="#000"/>
<LinearLayout android:id="#+id/lin00"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:orientation="horizontal">
<Button
android:layout_weight="0.1"
android:contentDescription="#string/ok"
android:id="#+id/okBtn"
android:layout_gravity="center"
android:layout_margin="10dp"
android:padding="10dp"
android:textSize="25dp"
android:background="#drawable/toolbar_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/ok"/>
<Button
android:layout_weight="0.1"
android:contentDescription="#string/ok"
android:id="#+id/selectBtn"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:padding="10dp"
android:textSize="25dp"
android:background="#drawable/toolbar_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/selectall"/>
<Button
android:layout_weight="0.1"
android:contentDescription="#string/cancel"
android:id="#+id/cancelBtn"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:padding="10dp"
android:textSize="25dp"
android:background="#drawable/toolbar_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cancel"/>
</LinearLayout>
</LinearLayout>
this is the code call the dialog box
private void showPopUp(int eid)
{
final AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
helpBuilder.setTitle("");
LayoutInflater inflater = getLayoutInflater();
final View PopupLayout = inflater.inflate(R.layout.jobselection, null);
helpBuilder.setView(PopupLayout);
final AlertDialog helpDialog = helpBuilder.create();
helpDialog.show();
okbtn = (Button)PopupLayout.findViewById(R.id.okBtn);
caneclbtn = (Button)PopupLayout.findViewById(R.id.cancelBtn);
selectallbtn = (Button)PopupLayout.findViewById(R.id.selectBtn);
clearallbtn = (Button)PopupLayout.findViewById(R.id.clearallBtn);
jobList = (ListView)PopupLayout.findViewById(R.id.list);
mylist = new ArrayList<HashMap<String, String>>();
for(int i=0;i<Punchedjobs.size();i++)
{
map = new HashMap<String, String>();
map.put("name", Punchedjobs.get(i));
mylist.add(map);
}
sd = new SimpleAdapter(StaffTimeClock.this,mylist,R.layout.jobslist,
new String[]{"name"},new int[]{R.id.jobText});
jobList.setAdapter(sd);
okbtn.setOnClickListener(new OnClickListener() {
public void onClick(View v)
{
\\code
}
});
caneclbtn.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
helpDialog.dismiss();
}
});
selectallbtn.setOnClickListener(new OnClickListener() {
public void onClick(View v)
{
}
);
}