Commit 6f889f48 authored by MUTTINENI NAVYA's avatar MUTTINENI NAVYA

created map for testing

parent eafb4d7d
...@@ -22,10 +22,12 @@ Bundle details_bundle; ...@@ -22,10 +22,12 @@ Bundle details_bundle;
Intent intent = getIntent(); Intent intent = getIntent();
details_bundle = intent.getExtras(); details_bundle = intent.getExtras();
TextView cat_row = (TextView) findViewById(R.id.category); ((TextView)findViewById(R.id.category)).setText(details_bundle.getString("category"));
cat_row.setText(details_bundle.getString("category")); ((TextView)findViewById(R.id.name)).setText(details_bundle.getString("name"));
TextView name_row = (TextView) findViewById(R.id.name); ((TextView) findViewById(R.id.place)).setText(details_bundle.getString("place"));
name_row.setText(details_bundle.getString("name")); ((TextView) findViewById(R.id.description)).setText(details_bundle.getString("description"));
((TextView) findViewById(R.id.date)).setText(details_bundle.getString("date"));
findViewById(R.id.edit_post).setOnClickListener(this); findViewById(R.id.edit_post).setOnClickListener(this);
findViewById(R.id.resolve_post).setOnClickListener(this); findViewById(R.id.resolve_post).setOnClickListener(this);
...@@ -35,12 +37,12 @@ Bundle details_bundle; ...@@ -35,12 +37,12 @@ Bundle details_bundle;
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()){ switch (v.getId()){
case R.id.edit_post: case R.id.edit_post:
if(details_bundle.getInt("type") == 0){ if(details_bundle.getString("type").equals("lost")){
Intent intent = new Intent(ItemDetails.this, LostItem.class); Intent intent = new Intent(ItemDetails.this, LostItem.class);
intent.putExtras(details_bundle); intent.putExtras(details_bundle);
startActivity(intent); startActivity(intent);
} }
else if(details_bundle.getInt("type") == 1){ else if(details_bundle.getString("type").equals("found")){
Intent intent = new Intent(ItemDetails.this, FoundItem.class); Intent intent = new Intent(ItemDetails.this, FoundItem.class);
intent.putExtras(details_bundle); intent.putExtras(details_bundle);
startActivity(intent); startActivity(intent);
......
...@@ -10,6 +10,12 @@ import android.widget.ArrayAdapter; ...@@ -10,6 +10,12 @@ import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Toast; import android.widget.Toast;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MyPosts extends AppCompatActivity { public class MyPosts extends AppCompatActivity {
String items[] = new String[] {"apple", "banana"}; String items[] = new String[] {"apple", "banana"};
...@@ -18,9 +24,36 @@ public class MyPosts extends AppCompatActivity { ...@@ -18,9 +24,36 @@ public class MyPosts extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_posts); setContentView(R.layout.activity_my_posts);
ListView listView = (ListView) findViewById(R.id.listview); final List<Map<String, String>> of = new ArrayList<Map<String, String>>();
List<Map<String, String>> ol = new ArrayList<Map<String, String>>();
Map<String, String> of1 = new HashMap<String, String>();
of1.put("key", "123");
of1.put("category","electronics");
of1.put("name","Phone");
of1.put("description","Lenovo Z+. Black colour.");
of1.put("date","28th Oct 2019");
of1.put("type","found");
of1.put("place","CC103");
of.add(of1);
Map<String, String> of2 = new HashMap<String, String>();
of2.put("key", "456");
of2.put("category","money");
of2.put("name","wallet");
of2.put("description","green colour baggit");
of2.put("date","28th Oct 2019");
of2.put("type","found");
of2.put("place","sic201");
of.add(of2);
String of_names[] = new String[of.size()];
for(int i=0; i<of.size();i++){
of_names[i] = of.get(i).get("name");
}
ListView listView = (ListView) findViewById(R.id.listviewlost);
ArrayAdapter<String> adaptor = new ArrayAdapter<String>(this, ArrayAdapter<String> adaptor = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items); android.R.layout.simple_list_item_1, of_names);
listView.setAdapter(adaptor); listView.setAdapter(adaptor);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
...@@ -29,9 +62,12 @@ public class MyPosts extends AppCompatActivity { ...@@ -29,9 +62,12 @@ public class MyPosts extends AppCompatActivity {
Toast.makeText(MyPosts.this, items[position], Toast.LENGTH_SHORT).show(); Toast.makeText(MyPosts.this, items[position], Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MyPosts.this, ItemDetails.class); Intent intent = new Intent(MyPosts.this, ItemDetails.class);
intent.putExtra("category", "Electronics"); intent.putExtra("category", "Electronics");
intent.putExtra("name", "Phone"); intent.putExtra("name", of.get(position).get("name"));
intent.putExtra("key", "123"); intent.putExtra("place", of.get(position).get("place"));
intent.putExtra("type", 0); intent.putExtra("description", of.get(position).get("description"));
intent.putExtra("date", of.get(position).get("date"));
intent.putExtra("key", of.get(position).get("key"));
intent.putExtra("type", of.get(position).get("type"));
startActivity(intent); startActivity(intent);
} }
}); });
......
...@@ -52,6 +52,63 @@ ...@@ -52,6 +52,63 @@
android:text="" /> android:text="" />
</TableRow> </TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:layout_width="114dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="Place" />
<TextView
android:id="@+id/place"
android:layout_width="171dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:text="" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:layout_width="114dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="Description" />
<TextView
android:id="@+id/description"
android:layout_width="171dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:text="" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:layout_width="114dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="Date" />
<TextView
android:id="@+id/date"
android:layout_width="171dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:text="" />
</TableRow>
</TableLayout> </TableLayout>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<ListView <ListView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/listview"> android:id="@+id/listviewlost">
</ListView> </ListView>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment