I'm trying to display the username and a photo in a a list view using the ParseQueryAdapter. I have the classes: User and Post.
I set it up here:
String[] postsObjectIds = some_string_array
ParseQueryAdapter<Post> adapter = new ParseQueryAdapter<Post>(getActivity(), new ParseQueryAdapter.QueryFactory<Post>() {
public ParseQuery<Post> create() {
ParseQuery<Post> query = Post.getQuery();
query.include("User");
query.whereContainedIn("objectId", Arrays.asList(postsObjectIds));
return query;
}
});
adapter.setTextKey("username");
adapter.setImageKey("photo");
adapter.setPlaceholder(getResources().getDrawable(R.drawable.some_drawable));
ListView listView = (ListView) rootView.findViewById(R.id.post_list_view);
listView.setAdapter(adapter);
The Post class has a column called photo and the User class has a column called username. The list view isn't displaying the username.
Do I have to implement a custom adapter?
Is there a quick fix?
I found an answer on the Parse Help Forum:
ParseQueryAdapter setTextKey for relational object
The accepted answer says to use a custom ParseQueryAdapter<T> and Override the getItemView.
For example, in my Fragment's onCreateView method, I initialized the adapter and set it (postsObjectIds is some String[]):
PostViewListViewAdapter adapter = new PostViewListViewAdapter(getActivity(), postsObjectIds);
ListView listView = (ListView) rootView.findViewById(R.id.post_list_view);
listView.setAdapter(adapter);
Here's my adapter (PostViewListViewAdapter):
public class PostViewListViewAdapter extends ParseQueryAdapter<Post> {
private final String[] mPostsObjectIds;
public PostViewListViewAdapter(Context context, final String[] postsObjectIds) {
super(context, new ParseQueryAdapter.QueryFactory<Post>(){
public ParseQuery<Post> create() {
ParseQuery<Post> query = Post.getQuery();
query.include("User");
query.whereContainedIn("objectId", Arrays.asList(postsObjectIds));
return query;
}
});
this.mPostsObjectIds = postsObjectIds;
}
#Override
public View getItemView(Post post, View v, ViewGroup parent) {
if(v == null) {
v = View.inflate(getContext(), R.layout.list_item_post_view, null);
}
super.getItemView(post, v, parent);
final TextView usernameTextView = (TextView) v.findViewById(R.id.username_text_view);
post.getCreator().fetchIfNeededInBackground(new GetCallback<ParseUser>() {
#Override
public void done(ParseUser user, ParseException e) {
usernameTextView.setText(user.getUsername());
}
});
return v;
}
}
Related
I'm working on an Android application of booking medicine offline. I have used ListView for Cart, but whenever I add a new item in cart, my previous item get replaced.
L1 = imageacidity
L2 = imagecough
if(msg.toString().equals("L1")) {
adapter = new ContactImageAdapter(this, R.layout.list, imageacidity);
ListView dataList = (ListView) findViewById(R.id.list);
dataList.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
if(msg.toString().equals("L2"))
{
adapter = new ContactImageAdapter(this, R.layout.list, imagecough);
ListView dataList = (ListView) findViewById(R.id.list);
dataList.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
Here I have 5 elements in imageacidity and Imagecough Array. Whenever I select 1 item, it gets added in cart, but when I try to select another item it get replaced with new one.
You have to Add the element inside your adapter.
I will post a custom Adapter and show you how to add elements properly.
Adapter:
public class YourAdapter extends BaseAdapter {
List<String> itens;
private Context mContext;
private static LayoutInflater inflater = null;
public YourAdapter(Context context, List<String> itens){
this.itens = itens;
mContext = context;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
return itens.size();
}
public String getItem(int position) {
return itens.get(position);
}
public long getItemId(int position) {
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
if (convertView == null)
vi = inflater.inflate(R.layout.list_row, parent, false);
String msg = itens.get(position);
TextView tx = vi.findViewById(R.id.your_id);
tx.setText(msg);
return vi;
}
public void addItem(String item){
itens.add(item);
}
public void addItens(List<String> itens){
this.itens.addAll(itens);
}
}
ListView:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adapter = new CustomAdapter(this,yourListOfItens);
listView = (ListView) findViewById(R.id.list_view);
listView.setAdapter(adapter);
}
You can set initial data on constructor of adapter, or use methods addItem and addAll on a click button for example.
The problem you are describing of the data being removed is happening because making a new ContactImageAdapter and calling setAdapter, which will completely remove the data that was already in the ListView.
If you want to properly implement the code in the question, you need something like this.
String msg = ""; // TODO: get this String value
ListView dataList = (ListView) findViewById(R.id.list);
// TODO: Define a single List to store the data and use that in *one* adapter
List<Contact> contacts = new ArrayList<Contact>();
adapter = new ContactImageAdapter(this, R.layout.list, contacts);
dataList.setAdapter(adapter);
// TODO: Replace this with the object to add to the adapter
Contact contact = null;
if(msg.equals("L1")) {
// TODO: Use whatever values you want for "L1"
int img = R.drawable.bati_acidity_1;
String name = "Amlapitta";
String price = "price 170";
contact = new Contact(img, name, price);
}
else if(msg.equals("L2")) {
// TODO: Use whatever values you want for "L2"
int img = R.drawable.bati_acidity_2;
String name = "Amlapitta2";
String price = "price 270";
contact = new Contact(img, name, price);
}
if (contact != null) {
contacts.add(contact);
adapter.notifyDataSetChanged();
}
Another problem is that you are calling notifyDataSetChanged without actually changing the datasets of imageacidity or imagecough.
You can use an algorithm (logic) on the InputListAdapter checking and verifying if there is a MedicineVO (Value Object Pattern) item on old list before the calling notyChange(..) method. In addition, you can wrapping the logic in other class such as MedicineLogic to improve the adapter readability.
See the sample code below:
public class MedicineInputListAdapter extends ArrayAdapter<MedicineVo> {
public static final int[] COLORS = new int[] { Color.WHITE, Color.BLUE };
private Context mContext;
private List<MedicineVo> medicineVos;
private MedicineVo medicineVoActual;
public BasePreOSPreventivaCorretivaInputListAdapter(Context context, int resource, List<MedicineVo> medicineVos) {
super(context, resource, medicineVos);
this.medicineVoActual = new MedicineVo();
this.medicineVos = new ArrayList<MedicineVo>();
this.medicineVos.addAll(medicineVos);
this.mContext = context;
}
private static class ViewHolder {
TextView mMedicineTextView;
//------------------------------------------------------
// others Android view components
//------------------------------------------------------
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder viewHolder;
if (convertView == null) {
//------------------------------------------------------
// mapper from xml to view and add itens to holder
//------------------------------------------------------
//------------------------------------------------------
// add event action to the mMedicineTextView
//------------------------------------------------------
viewHolder.mMedicineTextView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
TextView textView = (TextView) view;
MedicineVo medicineVo = (MedicineVo) textView.getTag();
boolean selected = medicineVo.getSelected();
if (selected) {
/*do it*/
}
refreshPreOSMaterialWhenUpdate(preOSMaterialVo);
}
});
convertView.setTag(viewHolder);
}
else {
viewHolder = (ViewHolder) convertView.getTag();
}
//------------------------------------------------------
// get item and adjust color
//------------------------------------------------------
MedicineVo item = getItem(position);
/*do it*/
return convertView;
}
public void refreshMedicineListWhenUpdate(MedicineVo medicineVo){
List<MedicineVo> newMedicineVos = new ArrayList<MedicineVo>();
for (MedicineVo medicineVoOnList : medicineVos) {
if( StringUtils.isNull(medicineVoOnList.getId()) )
continue;
if( MedicineLogic.existsOnList(medicineVos, medicineVoOnList) )
continue;
/* others checks if necessary */
newMedicineVos.add(medicineVoOnList);
}
medicineVos.addAll(newMedicineVos);
}
}
If you can't select more but only one item of your ListView, this might help.As others have commented on the question, changing the adapter of a ListView can clear the selection too, but as I supposed the code you've posted is inside onCreate (or other kind of initialization) so setting the adapter there won't affect the selection (since there can't be selection without items... :) )
I am struggling with a very weird Parse (Parse.com) problem:
When I use the usual list.setAdapter(Adapter);, I get the Error: "This query has an outstanding network connection. You have to wait until it's done."
Here is my code:
private ParseQueryAdapter<ParseObject> Adapter;
private CommentListAdapter CommentListAdapter;
Adapter = new ParseQueryAdapter<ParseObject>(this, "Activity");
Adapter.setTextKey("title");
// Initialize the subclass of ParseQueryAdapter
CommentListAdapter = new CommentListAdapter(this);
// Initialize ListView and set initial view to Adapter
CommentList.setAdapter(Adapter);
Adapter.loadObjects();
if (CommentList.getAdapter() == Adapter) {
CommentList.setAdapter(CommentListAdapter);
CommentListAdapter.loadObjects();
}else{
CommentList.setAdapter(Adapter);
Adapter.loadObjects();
}
I get the error at "CommentList.setAdapter(Adapter);"
Here is my Adapter:
public class CommentListAdapter extends ParseQueryAdapter<ParseObject> {
private List<String> itemList;
private Context context;
public ParseImageView thumbnailFile;
public TextView UsernameView;
public TextView Comments;
public CommentListAdapter(Context context) {
// Use the QueryFactory to construct a PQA that will only show
// Todos marked as high-pri
super(context, new ParseQueryAdapter.QueryFactory<ParseObject>() {
public ParseQuery create() {
ParseQuery query = new ParseQuery("Activity");
query.whereEqualTo("photoId", CommentActivity.getPhoto());
query.whereEqualTo("type", "comment");
query.orderByAscending("created_at");
Log.e("Log", "Query: " + query.countInBackground().toString());
return query;
}
});
}
// Customize the layout by overriding getItemView
#Override
public View getItemView(ParseObject object, View v, ViewGroup parent) {
if (v == null) {
v = View.inflate(getContext(), R.layout.comment_list_items, null);
}
super.getItemView(object, v, parent);
Log.e("Log", "Comment: " + object.toString());
thumbnailFile = (ParseImageView) v.findViewById(R.id.user_thumbnail);
UsernameView = (TextView) v.findViewById(R.id.user_name);
Comments = (TextView) v.findViewById(R.id.comment);
String Content = object.toString();
Comments.setText(Content);
return v;
}
}
Please help me, this kind of error should occur in such a case, I don't know what to do..
If you need more of my code, just tell me.
Updated code; however I am still getting no results when running the app.
I am using ParseQueryAdapter; I am querying the user, so am using ParseUser; it seems the first part is a query for all users of type midwife, then getting specific types of data I want, setting them to the TextViews
public class CustomMidwifeAdapter extends ParseQueryAdapter<ParseUser> {
public CustomMidwifeAdapter(Context context) {
// Use the QueryFactory to construct a PQA that will only show
// Todos marked as high-pri
super(context, new ParseQueryAdapter.QueryFactory<ParseUser>() {
public ParseQuery create() {
ParseQuery<ParseUser> query = new ParseQuery<ParseUser>("userType");
query.whereEqualTo("userType", "midwife");
query.findInBackground(new FindCallback<ParseUser>() {
#Override
public void done(List<ParseUser> parseUsers, ParseException e) {
if (e == null ) {
//query was successful
}
else {
//Something went wrong
}
}
});
return query;
}
});
}
public View getItemView(ParseUser object, View view, ViewGroup parent) {
if (view == null) {
view = View.inflate(getContext(), R.layout.activity_midwife_result_list, null);
}
super.getItemView(object, view, parent);
// Add the practicename view
TextView titleTextView = (TextView) view.findViewById(R.id.practicename);
titleTextView.setText(object.getString("practicename"));
// Add education view
TextView EducationView = (TextView) view.findViewById(R.id.education);
EducationView.setText(object.getString("education"));
// Add yearsexperience view
TextView ExperienceView = (TextView) view.findViewById(R.id.yearsinpractice);
ExperienceView.setText(object.getString("yearsinpractice"));
//Add practice philosophy view
TextView PracticePhilosophyView = (TextView) view.findViewById(R.id.practicephilosophy);
PracticePhilosophyView.setText(object.getString("practicephilosophy"));
return view;
}
}
Here is the activity
public class MidwifeResultList extends Activity {
private ParseQueryAdapter<ParseObject> mainAdapter;
private CustomMidwifeAdapter midwifeListAdapter;
private ListView listView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_list)
//initialize main ParseQueryAdapter
mainAdapter = new ParseQueryAdapter<ParseObject>(this, "userType");
mainAdapter.setTextKey("practicename");
mainAdapter.setTextKey("education");
mainAdapter.setTextKey("yearsinpractice");
mainAdapter.setTextKey("practicephilosophy");
// Initialize the subclass of ParseQueryAdapter
midwifeListAdapter = new CustomMidwifeAdapter(this);
// Initialize ListView and set initial view to mainAdapter
listView = (ListView) findViewById(R.id.lvMidwives);
listView.setAdapter(mainAdapter);
mainAdapter.loadObjects();
}
I've checked my listview, and the id's seem to be correct. This is based on this example: https://parse.com/tutorials/parse-query-adapter
When I ran my code I always get a log about Skipped 303 frames! The application may be doing too much work on its main thread. How to implement AsyncTask in this code below, and how to show a progressbar, while fetching data from one of my Parse.com's database. I would appreciate any help.
Here is my Activity's code:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_doctors_name_list);
Bundle extras = getIntent().getExtras();
final String key = extras.getString("KEY");
ListView lvDoctorsName = (ListView) findViewById(R.id.lvDoctorsName);
ParseQueryAdapter.QueryFactory<ParseObject> factory = new ParseQueryAdapter.QueryFactory<ParseObject>() {
public ParseQuery create() {
ParseQuery query = new ParseQuery("doctors");
query.whereContains("name", key);
return query;
}
};
CustomLayout urgentAdapter = new CustomLayout(this, factory);
lvDoctorsName.setAdapter(urgentAdapter);
TextView empty = (TextView) findViewById(R.id.empty_list_item);
lvDoctorsName.setEmptyView(empty);
itemClickListener();
}
public void itemClickListener() {
ListView lvDoctorsName = (ListView) findViewById(R.id.lvDoctorsName);
lvDoctorsName.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ParseObject item = (ParseObject) parent.getAdapter().getItem(position);
String objectID = item.getObjectId().toString();
Intent i = new Intent();
i.setClass(getApplicationContext(), DoctorPage.class);
//i.putExtra("new_variable_name",value);
i.putExtra("objectID", objectID);
startActivity(i);
}
});
}
And here my custom layout:
public class CustomLayout extends ParseQueryAdapter<ParseObject> {
public CustomLayout(Context context, QueryFactory<ParseObject> queryFactory) {
super(context, queryFactory);
}
#Override
public View getItemView(ParseObject object, View v, ViewGroup parent) {
if (v == null) {
v = View.inflate(getContext(), R.layout.row, null);
}
super.getItemView(object, v, parent);
TextView titleTextView = (TextView) v.findViewById(R.id.text1);
titleTextView.setText(object.getString("name"));
TextView titleTextView2 = (TextView) v.findViewById(R.id.text2);
titleTextView2.setText(object.getString("city"));
return v;
}
One problem I see is that you are calling findViewById() every time getItemView() is called; findViewById() is an expensive operation. You should implement something like the ViewHolder pattern to avoid this.
By the looks of the Parse documentation they take care of the AsyncTask for you. So that's not the problem.
Depending on the size of your data set, Emmanuel's answer with findViewById is correct.
To answer how to show a progress bar you can read the documentation on the ParseQueryAdapter, which lets you hook into loading / done loading triggers.
https://parse.com/docs/android/api/com/parse/ParseQueryAdapter.html
// Perhaps set a callback to be fired upon successful loading of a new set of ParseObjects.
adapter.addOnQueryLoadListener(new OnQueryLoadListener<ParseObject>() {
public void onLoading() {
// Trigger any "loading" UI
}
public void onLoaded(List<ParseObject> objects, ParseException e) {
// Execute any post-loading logic, hide "loading" UI
}
});
I need some help with my project. I've created a Custom Adapter, since I want my List View to display 5 textview, instead of one that I managed to do so far. This is my CustomAdapterPn activity:
public class CustomAdapterPn extends BaseAdapter {
private static ArrayList<Poniedzialek> searchPnArrayList;
private LayoutInflater mInflater;
public CustomAdapterPn(final Context context, final ArrayList<Poniedzialek> results) {
searchPnArrayList = results;
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return searchPnArrayList.size();
}
public Object getItem(int position) {
return searchPnArrayList.get(position);
}
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.entry, null);
holder = new ViewHolder();
holder.txtSession = (TextView) convertView.findViewById(R.id.textSession);
holder.txtName = (TextView) convertView.findViewById(R.id.textName);
holder.txtStart = (TextView) convertView.findViewById(R.id.textStartTime);
holder.txtEnd = (TextView) convertView.findViewById(R.id.textEndTime);
holder.txtRoom = (TextView) convertView.findViewById(R.id.textRoom);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.txtSession.setText(searchPnArrayList.get(position).getTypeOfSession());
holder.txtName.setText(searchPnArrayList.get(position).getName());
holder.txtStart.setText(searchPnArrayList.get(position).getStartTime());
holder.txtEnd.setText(searchPnArrayList.get(position).getEndTime());
holder.txtRoom.setText(searchPnArrayList.get(position).getRoom());
return convertView;
}
static class ViewHolder {
TextView txtSession;
TextView txtName;
TextView txtStart;
TextView txtEnd;
TextView txtRoom;
}
}
And this is Activity where I wish to use this CustomAdapter. Note that I was using ArrayAdapter to display list items - I didn't modify the code yet, since I am clueless what should I do to manage this custom adapter correctly ( I was trying to, but nothing worked out well ). I am a newbie, so it's quite hard for me to get this, although I was reading tons of tutorials.
public class PoniedzialekActivity extends Activity implements OnClickListener, OnItemClickListener{ // z ListActivity na Activity
private Button butPnAdd;
private Button butPnDelete;
private ListView list_Pn;
private static final int DIALOG_ALERT = 10;
// We need some kind of Adapter to made the connection between ListView UI component and SQLite data set.
private ListAdapter pn_list_adapter;
// We need this while we read the query using Cursor and pass data
private ArrayList<Poniedzialek> pn_list;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_poniedzialek);
butPnAdd = (Button) findViewById(R.id.butPnAdd);
butPnAdd.setOnClickListener(this);
butPnDelete = (Button) findViewById(R.id.butPnDel);
butPnDelete.setOnClickListener(this);
// Initialize UI components
list_Pn = (ListView) findViewById(R.id.listPn);
list_Pn.setOnItemClickListener(this);
pn_list = new ArrayList<Poniedzialek>();
// For the third argument, we need a List that contains Strings.
//We decided to display undergraduates names on the ListView.
//Therefore we need to create List that contains undergraduates names
pn_list_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList());
list_Pn.setAdapter(pn_list_adapter);
}
#Override
public void onClick(View v) {
if(v.getId()==R.id.butPnAdd){
Intent i = new Intent(PoniedzialekActivity.this,dodawaniePoniedzialek.class);
startActivity(i);
}
if(v.getId()==R.id.butPnDel){
showDialog(DIALOG_ALERT);
}
}
/**
* DIALOG
*/
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_ALERT:
// Create out AlterDialog
Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Czy na pewno chcesz usunac wszystkie wpisy ?");
builder.setCancelable(true);
builder.setPositiveButton("Tak", new OkOnClickListener());
builder.setNegativeButton("Nie", new CancelOnClickListener());
AlertDialog dialog = builder.create();
dialog.show();
}
return super.onCreateDialog(id);
}
private final class CancelOnClickListener implements
DialogInterface.OnClickListener {
public void onClick(DialogInterface dialog, int which) {
// Nic nie robi
}
}
private final class OkOnClickListener implements
DialogInterface.OnClickListener {
public void onClick(DialogInterface dialog, int which) {
DeletePn();
onResume();
}
}
public void DeletePn(){
DatabaseHelper openHelperClass = new DatabaseHelper(this);
SQLiteDatabase sqliteDatabase = openHelperClass.getWritableDatabase();
sqliteDatabase.delete(DatabaseHelper.PN_TABLE, null, null);
}
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
}
// To create a List that contains undergraduate names, we have to read the SQLite database
//We are going to do it in the separate method
public List<String> populateList(){
// We have to return a List which contains only String values. Lets create a List first
List<String> pn_string_list = new ArrayList<String>();
// First we need to make contact with the database we have created using the DbHelper class
DatabaseHelper openHelperClass = new DatabaseHelper(this);
// Then we need to get a readable database
SQLiteDatabase sqliteDatabase = openHelperClass.getReadableDatabase();
// We need a a guy to read the database query. Cursor interface will do it for us
//(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy)
Cursor cursor = sqliteDatabase.query(DatabaseHelper.PN_TABLE, null, null, null, null, null, null);
// Above given query, read all the columns and fields of the table
startManagingCursor(cursor);
// Cursor object read all the fields. So we make sure to check it will not miss any by looping through a while loop
while (cursor.moveToNext()) {
// In one loop, cursor read one undergraduate all details
// Assume, we also need to see all the details of each and every undergraduate
// What we have to do is in each loop, read all the values, pass them to the POJO class
//and create a ArrayList of undergraduates
String session = cursor.getString(cursor.getColumnIndex(DatabaseHelper.PN_KEY_TYPE_OF_SESSION));
String start = cursor.getString(cursor.getColumnIndex(DatabaseHelper.PN_KEY_START_TIME));
String end = cursor.getString(cursor.getColumnIndex(DatabaseHelper.PN_KEY_END_TIME));
String name = cursor.getString(cursor.getColumnIndex(DatabaseHelper.PN_KEY_NAME));
String room = cursor.getString(cursor.getColumnIndex(DatabaseHelper.PN_KEY_ROOM));
// Finish reading one raw, now we have to pass them to the POJO
Poniedzialek pn = new Poniedzialek();
pn.setTypeOfSession(session);
pn.setName(name);
pn.setStartTime(start);
pn.setEndTime(end);
pn.setRoom(room);
// Przekazujemy pn do arraylist
pn_list.add(pn);
// But we need a List of String to display in the ListView also.
// That is why we create "pn_string_list"
pn_string_list.add(name);
}
// Jezeli Baza Danych nie zostanie zamknieta dostaniemy error
sqliteDatabase.close();
return pn_string_list;
}
// If you don't write the following code, you wont be able to see what you have just insert to the database
#SuppressWarnings("unchecked")
#Override
protected void onResume() {
super.onResume();
pn_list_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList());
list_Pn.setAdapter(pn_list_adapter);
((ArrayAdapter<String>) pn_list_adapter).notifyDataSetChanged(); // dodano
list_Pn.refreshDrawableState(); // dodanoe
list_Pn.invalidate(); // dodanoe
}
} // end PoniedzialekActivity
Create an object for your custom adapter class CustomAdapterPn and set this custom adapter object to list view . Not the array adapter .
Look at this lines and make changes according to it,
CustomAdapterPn pn_list_adapter; //change 1
pn_list = new ArrayList<Poniedzialek>();
populateList() // Change 2
pn_list_adapter = new CustomAdapterPn(this,pn_list); // Change 3
list_Pn.setAdapter(pn_list_adapter);
Try this and let me know what happen..