I have a listview. When one of items clicked, it is showing now only textview. But under textview, i will put a map. It must take also location.
So, i will create a new class, a new activity when clicked. But i need to send this location and textview text. How can i send?
Now i am putting only the class of listview. Right now, i have 2 views, when clicked other view is coming. No fragment, no activity:
package cursedchico.showmeevets;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
public class ListEvents extends AppCompatActivity {
private String type;
ListView lv;
private TextView desc;
private View listView, showView;
private Context mContext ;
DBHandler db;
private List<Event> events;
ProgressDialog dialog;
// @Override
// public void onBackPressed(){
// setContentView(listView);
// }
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.v(TAG, "ListEvents activity oncreate");
mContext = getBaseContext();
db = new DBHandler(mContext);
if(db==null) Log.v(TAG, "null ");
if(mContext==null) Log.v(TAG, "mnull ");
Intent myIntent = getIntent(); // gets the previously created intent
type = myIntent.getStringExtra("Type");
Log.v(TAG, "Type: " + type);
listView = getLayoutInflater().inflate(R.layout.activity_list, null);
showView = getLayoutInflater().inflate(R.layout.show_description, null);
setContentView(listView);
lv = (ListView) findViewById(R.id.list);
Log.v(TAG,"setadapter oncesı");
int[] colors = {0, 0xFFFF0000, 0}; // red for the example
lv.setDivider(new GradientDrawable(GradientDrawable.Orientation.RIGHT_LEFT, colors));
lv.setDividerHeight(1);
events = new ArrayList();
events = db.getSomeEvents(type);
//burdan baska bir ekrana gitmesi iyi olur cunku duruyor bos bos oyle
if(events==null) { Toast.makeText(getApplication(), "ETKINLIK BULUNAMADI ...",
Toast.LENGTH_LONG).show();}
else {
lv.setAdapter(new CustomAdapter(this, events));
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Log.v(TAG, "tıklandi, şurdaki: " + position);
// Object o = lv.getItemAtPosition(position);
//Log.v(TAG, "tıklandi1 desc: " + events.get(position).getDescription());
// Wrapper wra = (Wrapper)o;
// Log.v(TAG, "tıklandi2");
desc = (TextView) showView.findViewById(R.id.desc);
//Log.v(TAG, "tıklandi3");
desc.setText(events.get(position).getDescription());
Log.v(TAG, "desc view geçiş");
setContentView(showView);
}//geri tusuna basınca maine gidiyor
});
}//else sonu
}//oncreate sonu
}
Maybe i can put map into this layout and let it stay inside this class but it will be very complicated. I dont know how to use fragments, a new activity seems good but i dont know how to send when creating intend. Can i send via creating construct of that map class but this time how can that map class will take the view and make layout?