I have created a custom arrayadapter, that causes me the list of elements from a request "get" from soundcloud, but when I click on one of the elements gives me this message:
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
here is my code:
Activity
package com.giuseppemorra.domusic;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import cz.msebera.android.httpclient.HttpResponse;
import cz.msebera.android.httpclient.NameValuePair;
import cz.msebera.android.httpclient.client.HttpClient;
import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity;
import cz.msebera.android.httpclient.client.methods.HttpGet;
import cz.msebera.android.httpclient.client.methods.HttpPost;
import cz.msebera.android.httpclient.impl.client.DefaultHttpClient;
import cz.msebera.android.httpclient.impl.client.HttpClients;
import cz.msebera.android.httpclient.message.BasicNameValuePair;
import cz.msebera.android.httpclient.util.EntityUtils;
public class Second extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener{
Adapter adapter;
ListView lista;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
#Override
protected void onStart(){
super.onStart();
Bundle extras = getIntent().getExtras();
if (extras != null) {
String musica = extras.getString("musica");
String ric = musica;
new Mod().execute(ric);
}
}
#Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
return super.onOptionsItemSelected(item);
}
#SuppressWarnings("StatementWithEmptyBody")
#Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_camera) {
// Handle the camera action
} else if (id == R.id.nav_gallery) {
} else if (id == R.id.nav_slideshow) {
} else if (id == R.id.nav_manage) {
} else if (id == R.id.nav_share) {
} else if (id == R.id.nav_send) {
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
private class Mod extends AsyncTask<String, Integer, String> {
protected String doInBackground(String... parametri) {
String par = Arrays.toString(parametri);
par = par.replace("[", "");
par = par.replace("]", "");
String[] risultati = par.split(",");
String musica = risultati[0];
Log.d("cell", musica);
HttpClient httpclient = HttpClients.createDefault();
HttpGet httppost = new HttpGet();
String gio = "";
try {
URI website = new URI("http://api.soundcloud.com/tracks/?client_id=4ee809712e980dfc07b9e8af6f42d434&limit=200&&q="+URLEncoder.encode(musica,"UTF-8"));
httppost.setURI(website);
HttpResponse response = httpclient.execute(httppost);
BufferedReader in = new BufferedReader(new InputStreamReader( response.getEntity().getContent()));
String line = in.readLine();
Log.d("Risposta dal server", line);
gio = line;
} catch (IOException | URISyntaxException b) {
b.printStackTrace();
b.printStackTrace();
}
return gio;
}
protected void onProgressUpdate(String... progress) {
}
protected void onPostExecute(String result) {
String str = result;
Log.d("new",str);
JSONArray jArrayObject;
try {
jArrayObject = new JSONArray(str);
String[] datiFin = new String[jArrayObject.length()];
String[] titleFin = new String[jArrayObject.length()];
String[] durataFin = new String[jArrayObject.length()];
String[] avatar_urlFin = new String[jArrayObject.length()];
for (int i = 0; i<jArrayObject.length(); i++) {
String stream = jArrayObject.getJSONObject(i).getString("stream_url").toString();
String id = jArrayObject.getJSONObject(i).getString("id").toString();
String title = jArrayObject.getJSONObject(i).getString("title").toString();
String durata = jArrayObject.getJSONObject(i).getString("duration").toString();
JSONObject jObj = new JSONObject(jArrayObject.getJSONObject(i).getString("user").toString());
String avatar_url = jObj.getString("avatar_url").toString();
datiFin[i] = stream.concat(",").concat(id);
titleFin[i] = title;
int minutes = (int) ((Integer.parseInt(durata) / (1000*60)) % 60);
String durataFinale = minutes+" Minuti";
durataFin[i] = durataFinale;
avatar_urlFin[i] = avatar_url;
}
lista = (ListView)findViewById(R.id.musica_lista);
lista.setFastScrollEnabled(true);
adapter = new com.giuseppemorra.domusic.Adapter(Second.this,titleFin,datiFin,durataFin,avatar_urlFin);
lista.setAdapter((ListAdapter) adapter);
lista.setOnItemClickListener(new OnItemClickListener(){
#SuppressWarnings("unchecked")
public void onItemClick(AdapterView<?> parent, View v, int position,long id) {
Log.d("ciao","ciao");
}
});
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
ArrayAdaptery:
package com.giuseppemorra.domusic;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.squareup.picasso.Picasso;
import org.w3c.dom.Text;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
public class Adapter extends ArrayAdapter<String> {
String[] titolo, dati, durata, avatar;
Context context;
Holder holder;
public Adapter(Context context, String[] titolo, String[] dati, String[] durata, String[] avatar) {
super(context, R.layout.lista_musica, titolo);
// TODO Auto-generated constructor stub
this.titolo = titolo;
this.avatar = avatar;
this.durata = durata;
this.dati = dati;
this.context = context;
}
public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
holder = new Holder();
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.lista_musica, null, true);
holder.titoloMod = (TextView) view.findViewById(R.id.titoloMusica);
holder.avatarMod = (ImageView) view.findViewById(R.id.immagieMusica);
holder.durataMod = (TextView) view.findViewById(R.id.durataMusica);
holder.contMod = (TextView) view.findViewById(R.id.contDati);
holder.titoloMod.setText(titolo[position]);
holder.durataMod.setText(durata[position]);
holder.contMod.setText(dati[position]);
Picasso.with(context).load(avatar[position]).into(holder.avatarMod);
view.setTag(holder);
} else {
holder = (Holder) view.getTag();
}
return view;
}
#Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
}
class Holder {
TextView titoloMod, durataMod, contMod;
ImageView avatarMod;
}
ListView:
<?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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.giuseppemorra.domusic.Second"
tools:showIn="#layout/second_bar_main"
android:focusable="false"
android:clickable="false">
<ListView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/musica_lista"
android:scrollingCache="false"
android:smoothScrollbar="true"
android:clickable="true" />
</LinearLayout>
Single item:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:clickable="true" >
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="#+id/immagieMusica"
android:layout_margin="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/titoloMusica"
android:layout_alignTop="#+id/immagieMusica"
android:layout_toEndOf="#+id/immagieMusica"
android:textSize="10dp"
android:textIsSelectable="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="#+id/durataMusica"
android:layout_alignBottom="#+id/immagieMusica"
android:layout_toEndOf="#+id/immagieMusica" />
<EditText
android:layout_width="0dp"
android:layout_height="0dp"
android:id="#+id/contDati"
android:layout_above="#+id/durataMusica"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Then I would understand where I'm wrong, and how to perform the function qaundo you click on one of the list elements
Related
This is the code I have been working on for a while. The only issue is I cannot seem to be able to get the sum of values input into the editText fields that are dynamically added into the program and then place them into a pie chart. The data is to be transferred from the second activity to the third where the third activity will add up all resource amounts and display them into a pie chart.
SecondActivity.class
package com.example.a4mob;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.text.InputType;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatSpinner;
import androidx.drawerlayout.widget.DrawerLayout;
import java.util.ArrayList;
import java.util.List;
public class SecondActivity extends AppCompatActivity implements View.OnClickListener {
public DrawerLayout drawerLayout;
public ActionBarDrawerToggle actionBarDrawerToggle;
private LinearLayout linearLayout;
private Button add;
//for button add resource
List<String> ColourList = new ArrayList<>();
ArrayList<Results> resultList = new ArrayList<>();
private Button submit;
private Number uinput;
#Override
protected void onCreate(Bundle savedInstance){
super.onCreate(savedInstance);
setContentView(R.layout.secondactivity);
// drawer layout instance to toggle the menu icon to open
// drawer and back button to close drawer
drawerLayout = findViewById(R.id.my_drawer_layout);
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.nav_open, R.string.nav_close);
// pass the Open and Close toggle for the drawer layout listener
// to toggle the button
drawerLayout.addDrawerListener(actionBarDrawerToggle);
actionBarDrawerToggle.syncState();
// to make the Navigation drawer icon always appear on the action bar
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBar actionBar;
actionBar = getSupportActionBar();
// Define ColorDrawable object and parse color
// using parseColor method
// with color hash code as its parameter
ColorDrawable colorDrawable
= new ColorDrawable(Color.parseColor("grey"));
// Set BackgroundDrawable
actionBar.setBackgroundDrawable(colorDrawable);
//Adds more objects
linearLayout = findViewById(R.id.layout_list);
add = findViewById(R.id.CreateNew);
add.setOnClickListener(this);
ColourList.add("grey");
ColourList.add("green");
ColourList.add("blue");
ColourList.add("yellow");
// Creating submit button click listener
submit = findViewById(R.id.Submit);
submit.setOnClickListener(this);
}
public void onClick(View view){
switch (view.getId()){
case R.id.CreateNew:
addView();
break;
case R.id.Submit:
if(isValid()){
Intent intent = new Intent(SecondActivity.this, ThirdActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("list", resultList);
intent.putExtras(bundle);
startActivity(intent);
}
break;
}
}
private boolean isValid() {
resultList.clear();
boolean valid = true;
for(int i = 0; i < linearLayout.getChildCount(); i++){
View resultView = linearLayout.getChildAt(i);
EditText resultName = (EditText) resultView.findViewById(R.id.RName);
EditText resultNumber = (EditText) resultView.findViewById(R.id.RAmount);
AppCompatSpinner COP = (AppCompatSpinner) resultView.findViewById(R.id.ColourOP);
Results results = new Results();
if(!resultName.getText().toString().equals("")){
results.setResName(resultName.getText().toString());
}else{
valid = false;
break;
}
if(!resultNumber.getText().toString().equals("")){
results.setResAmount(Integer.parseInt(resultNumber.getText().toString()));
}else{
valid = false;
break;
}
if(COP.getSelectedItemPosition()!=0){
}else{
valid = false;
break;
}
resultList.add(results);
}
if(resultList.size() == 0){
valid = false;
Toast.makeText(this, "Complete all fields first", Toast.LENGTH_SHORT).show();
} else if(!valid){
Toast.makeText(this, "Enter details correctly", Toast.LENGTH_SHORT).show();
}
return valid;
}
public void addAmount(){
for(int i = 0; i < linearLayout.getChildCount(); i++) {
View resultView = linearLayout.getChildAt(i);
EditText resultNumber = (EditText) resultView.findViewById(R.id.RAmount);
Results results = new Results();
}
}
private void sub(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Please input inventory space:");
// Set up the input
final EditText input = new EditText(this);
// Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
input.setInputType(InputType.TYPE_CLASS_NUMBER);
builder.setView(input);
// Set up the buttons
builder.setPositiveButton("Continue", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
uinput = input.getInputType();
changeAct();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
private void changeAct(){
Intent intent = new Intent(this, ThirdActivity.class);
startActivity(intent);
}
private void addView(){
View newResource = getLayoutInflater().inflate(R.layout.row_add_data, null, false);
ImageView imageClose = (ImageView)newResource.findViewById(R.id.Remove);
TextView RN = (TextView) newResource.findViewById(R.id.RName);
TextView RA = (TextView) newResource.findViewById(R.id.RAmount);
AppCompatSpinner COP = (AppCompatSpinner) newResource.findViewById(R.id.ColourOP);
ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, ColourList);
COP.setAdapter(arrayAdapter);
imageClose.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
removeView(newResource);
}
});
linearLayout.addView(newResource);
}
private void removeView(View view){
linearLayout.removeView(view);
}
#Override
public boolean onOptionsItemSelected(#NonNull MenuItem item) {
if (actionBarDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
}
#Override
public void onPointerCaptureChanged(boolean hasCapture) {
super.onPointerCaptureChanged(hasCapture);
}
}
ThirdActivity.class
package com.example.a4mob;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
public class ThirdActivity extends AppCompatActivity {
RecyclerView recycle_results;
ArrayList<Results> resultList = new ArrayList<>();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.thirdactivity);
recycle_results = findViewById(R.id.res_results);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
recycle_results.setLayoutManager(linearLayoutManager);
resultList = (ArrayList<Results>) getIntent().getExtras().getSerializable("list");
recycle_results.setAdapter(new ResultsAdapter(resultList));
}
}
Results.class
package com.example.a4mob;
import java.io.Serializable;
public class Results implements Serializable {
public String resourceName;
public int resourceAmount;
public int totalAmount;
public Results(){
}
public int getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(int totalAmount) {
this.totalAmount = totalAmount;
}
public int getResAmount() {
return resourceAmount;
}
public void setResAmount(int resourceAmount) {
this.resourceAmount = resourceAmount;
}
public Results(String resourceName, int resourceAmount){
this.resourceName = resourceName;
this.resourceAmount = resourceAmount;
}
public String getResName() {
return resourceName;
}
public void setResName(String resourceName) {
this.resourceName = resourceName;
}
}
ResultsAdapter.class
package com.example.a4mob;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
public class ResultsAdapter extends RecyclerView.Adapter<ResultsAdapter.ResultsView> {
ArrayList<Results> resultList = new ArrayList<>();
int total;
public ResultsAdapter(ArrayList<Results> resultList) {
this.resultList = resultList;
}
#NonNull
#Override
public ResultsView onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_results,parent,false);
return new ResultsView(view);
}
#Override
public void onBindViewHolder(#NonNull ResultsView holder, int position) {
Results results = resultList.get(position);
holder.resourceName.setText(results.getResName());
holder.resourceAmount.setText(String.valueOf(results.getResAmount()));
}
#Override
public int getItemCount() {
return resultList.size();
}
public class ResultsView extends RecyclerView.ViewHolder{
TextView resourceName, resourceAmount, resourceTotal;
public ResultsView(#NonNull View itemView) {
super(itemView);
resourceName = (TextView) itemView.findViewById(R.id.resNa);
resourceAmount = (TextView) itemView.findViewById(R.id.resAm);
resourceTotal = (TextView) itemView.findViewById(R.id.resTot);
}
}
}
thirdactivity.xml
<?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="match_parent"
tools:context=".ThirdActivity">
<LinearLayout
android:id="#+id/layoutThird"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
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/res_results"
android:layout_width="match_parent"
android:layout_height="match_parent"></androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
row_results.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardBackgroundColor="#color/white"
android:layout_margin="5dp"
android:layout_marginBottom="20dp"
app:cardCornerRadius="10dp"
app:cardElevation="10dp">
<LinearLayout
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1"
android:layout_marginBottom="0dp">
<TextView
android:id="#+id/resNa"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Resource Name"
android:textSize="18sp"
android:textColor="#color/black"></TextView>
<TextView
android:id="#+id/resAm"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Resource Amount"
android:textSize="14sp"
android:textColor="#color/black"></TextView>
<TextView
android:id="#+id/resTot"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Resource Amount"
android:textSize="14sp"
android:textColor="#color/black"></TextView>
</LinearLayout>
</androidx.cardview.widget.CardView>
I want to change my Button text when i delete the items
i already checked it getText, when i getText it shows that the data
already changed but when i try to setText, it's not show to me
In this case what shold i do?
This is my f_productAdapter
package com.example.together.Adapter;
import android.content.Context;
import android.media.Image;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.example.together.Model.FuneralProdcutOrder;
import com.example.together.R;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.example.together.Activities.EditProfileActivity.TAG;
public class f_productAdapter extends BaseAdapter {
Button b;
LayoutInflater inflater = null;
private ArrayList<FuneralProdcutOrder> list;
public f_productAdapter(ArrayList<FuneralProdcutOrder> f_order) {
super();
list = f_order;
}
#Override
public int getCount() {
return list.size();
}
#Override
public Object getItem(int position) {
return list.get(position);
}
#Override
public long getItemId(int position) {
return list.get(position).hashCode();
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
if(convertView == null) {
inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.item_funeralorder, parent, false);
}
TextView tv_name = convertView.findViewById(R.id.productnm); //상품이름
TextView tv_price = convertView.findViewById(R.id.productpri); //상품 가격
ImageView tv_img = convertView.findViewById(R.id.pro_img);
Button tv_delete = convertView.findViewById(R.id.deleteBtn);
FuneralProdcutOrder getProlist = list.get(position);
tv_name.setText(getProlist.getName());
tv_price.setText(getProlist.getPrice());
Picasso.get().load(getProlist.getImg()).fit().into(tv_img);
LayoutInflater inflaters = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View Toplayout = inflaters.inflate(R.layout.activity_goodbyepet_reservation_result, null );
//
b = Toplayout.findViewById(R.id.f_orderBtn);
TextView test = Toplayout.findViewById(R.id.toolbar_title);
Log.e("test",test.getText()+"");
// Log.e("view context", parent.getContext()+"");
// Log.e("view position", position+"");
// Log.e("view count", list.size()+"");
// Log.e("view",b.getText()+"");
// b.setText("테스트");
b.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Log.e("view alert" ,"확실히 버튼 객체를 찾았습니다 눌림");
}
});
tv_delete.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
list.remove(position);
b.setText("Show me~~~~ u r change!!!");
notifyDataSetChanged();
Log.d(TAG, "onClick: What is you?"+list.size());
}
});
return convertView;
}
}
This is my reservationResultActivity
package com.example.together.Activities.GoodbyePet;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.support.v7.widget.Toolbar;
import com.example.together.Adapter.f_productAdapter;
import com.example.together.Model.FuneralProdcutOrder;
import com.example.together.R;
import java.lang.reflect.Array;
import java.util.ArrayList;
public class GoodbyepetReservationResultActivity extends AppCompatActivity {
// private TextView tvParent, tvChild;
Toolbar myToolbar;
ListView funeralview;
Button Btn;
private ArrayList<FuneralProdcutOrder> f_order = new ArrayList<>();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_goodbyepet_reservation_result);
int total_price = 0;
//리스트뷰선언
funeralview = findViewById(R.id.funeral_order);
//예약 버튼
Btn = findViewById(R.id.f_orderBtn);
//툴바 선언
myToolbar = findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);
//액션바 왼쪽에 버튼
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_btn_back);
getSupportActionBar().setDisplayShowTitleEnabled(false);
for (int i = 0; i < MyCategoriesExpandableListAdapter.parentItems.size(); i++ ) {
for (int j = 0; j < MyCategoriesExpandableListAdapter.childItems.get(i).size(); j++ ){
String isChildChecked = MyCategoriesExpandableListAdapter.childItems.get(i).get(j).get(ConstantManager.Parameter.IS_CHECKED);
if (isChildChecked.equalsIgnoreCase(ConstantManager.CHECK_BOX_CHECKED_TRUE)) {
// tvParent.setText(tvParent.getText() + MyCategoriesExpandableListAdapter.childItems.get(i).get(j).get(ConstantManager.Parameter.SUB_CATEGORY_NAME));
// tvChild.setText(tvChild.getText() + MyCategoriesExpandableListAdapter.childItems.get(i).get(j).get(ConstantManager.Parameter.SUB_CATEGORY_PRICE));
String name = MyCategoriesExpandableListAdapter.childItems.get(i).get(j).get(ConstantManager.Parameter.SUB_CATEGORY_NAME);
String price = MyCategoriesExpandableListAdapter.childItems.get(i).get(j).get(ConstantManager.Parameter.SUB_CATEGORY_PRICE);
String img = MyCategoriesExpandableListAdapter.childItems.get(i).get(j).get(ConstantManager.Parameter.SUB_CATEGORY_IMAGE);
f_order.add(new FuneralProdcutOrder(name,price,img));
total_price = total_price + Integer.parseInt(price);
}
}
}
f_productAdapter orAdapter = new f_productAdapter(f_order);
// orAdapter.setHasStableId(true);
Log.e("view activiey", f_order.size()+"안녕");
funeralview.setAdapter(orAdapter);
Btn.setText(f_order.size()+"개 " + total_price+" 원 예약 신청하기");
Btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
}
//액션바 등록
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.alldelete_manu, menu) ;
return true ;
}
//액션바 클릭 이벤트
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// ((TextView)findViewById(R.id.textView)).setText("SEARCH") ;
return true;
case R.id.settings:
// ((TextView)findViewById(R.id.textView)).setText("ACCOUNT") ;
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
What i want to do
when i delete the button directly change buttons text also change
but setText() is not working
how to change that?
Click delete button
tv_delete.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
list.remove(position);
b.setText("Show me~~~~ u r change!!!");
notifyDataSetChanged();
Log.d(TAG, "onClick: What is you?"+list.size());
}
});
What i want to change the button text
Btn.setText(f_order.size()+"개 " + total_price+" 원 예약 신청하기");
This is my XML That include button what i want to change the text
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="fill_parent"
tools:context=".Activities.GoodbyePet.GoodbyepetReservationResultActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/mdtp_white"
android:elevation="4dp"
android:theme="#style/ThemeOverlay.AppCompat.ActionBar">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="예약 상세서"
android:layout_gravity="center"
android:id="#+id/toolbar_title"
android:textSize="20sp"
/>
</android.support.v7.widget.Toolbar>
<ListView
android:id="#+id/funeral_order"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.3"
android:drawSelectorOnTop="false">
</ListView>
<Button
android:id="#+id/f_orderBtn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:layout_margin="10dp"
android:text="바뀌어주세요"
android:background="#drawable/button_radius"
android:textSize="18dp"/>
</LinearLayout>
Create an interface class like this;
You can set many kind of information as a parameter about your deleted item and send it to your activity.
public interface ItemSelectedListener{
void onItemSelected(boolean isDeleted);
}
In your adapter initialize your interface;
private List<ItemSelectedListener> mItemSelectedSubscribers = new ArrayList<ItemSelectedListener>();
Add this method in your adapter ;
public void subscribeItemSelection(ItemSelectedListener listener) {
mItemSelectedSubscribers .add(listener);
}
Set this loop in your click events;
tv_delete.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
for (ItemSelectedListener listener : mItemSelectedSubscribers ) {
listener.onItemSelected(true);
}
list.remove(position);
b.setText("Show me~~~~ u r change!!!");
notifyDataSetChanged();
Log.d(TAG, "onClick: What is you?"+list.size());
}
});
In your activity, implement your interface and you will set a implemented methods. this methods look like this;
boolean isDeleted;
#Override
public void onItemSelected(boolean isDeleted) {
this.isDeleted = isDeleted;
}
You know now item is deleted or not. When a button deleted you can change text by using your method.
if(isDeleted){
btn.setText(changeText)
}
Hope this help!
Here is the problem, I want my navigation drawer (the hamburger icon), only appears in certain fragment. In my case, I have three fragment, using tab layout and view pager to change between fragment. I have implement an interface which I have created. But when I set to true, the hamburger icon appear in all fragment. I don't know where my problem is in my code.
mainactivity code :
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.design.widget.TabLayout;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.Toolbar;
import android.text.Spannable;
import android.text.SpannableString;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import emptrack.toro.developer.com.emptrack.FastScroll.AlphabetItem;
import emptrack.toro.developer.com.emptrack.FastScroll.DataHelper;
import emptrack.toro.developer.com.emptrack.FastScroll.VendorAdapter;
import in.myinnos.alphabetsindexfastscrollrecycler.IndexFastScrollRecyclerView;
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, DrawerLocker{
private View view_menu, view_click, view_list;
private ImageView btn_arrow_back;
private TabLayout tabLayout;
private ViewPager viewPager;
private ViewPagerAdapter adapter;
private Bundle intentFragment;
private String frag;
private ArrayList<ListPegawai> dataBaru;
private Bundle dapatData;
String PREFERENCES_FILE_NAME = "preference_diri";
SharedPreferences dataDiri, retrieveData;
//Untuk filtering
private List<String> mDataArray;
//Side bar
private DrawerLayout drawer;
ActionBarDrawerToggle toggle;
Toolbar toolbar;
private List<AlphabetItem> mAlphabetItems;
private IndexFastScrollRecyclerView mRecyclerView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Filtering
mRecyclerView = findViewById(R.id.fast_scroller_recycler);
mDataArray = new ArrayList<String>();
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//ganti ActionBar font
SpannableString s = new SpannableString("EmpTrack");
s.setSpan(new TypefaceSpan(this, "raleway_semibold.ttf"), 0, s.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ActionBar actionBar = getSupportActionBar();
actionBar.setElevation(0);
actionBar.setTitle(s);
tabLayout = (TabLayout) findViewById(R.id.tabLayout);
viewPager = (ViewPager) findViewById(R.id.viewPager);
adapter = new ViewPagerAdapter(getSupportFragmentManager());
dataDiri = getSharedPreferences(PREFERENCES_FILE_NAME, MODE_PRIVATE);
SharedPreferences.Editor editor = dataDiri.edit();
adapter.addFragment(new FragmentNews(), "News");
adapter.addFragment(new FragmentTracking(), "Tracking");
adapter.addFragment(new FragmentSettings(), "Settings");
viewPager.setOffscreenPageLimit(3);
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);
//Init layout
view_menu = (View) findViewById(R.id.menu_layout);
view_list = (View) findViewById(R.id.list_vendor2);
view_click = (View) findViewById(R.id.click_vendor);
btn_arrow_back = (ImageView) findViewById(R.id.arrow_back);
//Untuk sidebar
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
//Init filtering
initialiseData();
initialiseUI();
tabLayout.getTabAt(0).setIcon(R.drawable.ic_news);
tabLayout.getTabAt(1).setIcon(R.drawable.ic_tracking);
tabLayout.getTabAt(2).setIcon(R.drawable.ic_settings);
actionBar.setElevation(0);
intentFragment = getIntent().getExtras();
if (intentFragment != null) {
frag = intentFragment.getString("LoadFragment");
switch (frag) {
case "tracking":
viewPager.setCurrentItem(1, true);
break;
case "settings":
viewPager.setCurrentItem(2, true);
break;
}
}
//Fungsi click untuk sidebar
view_click.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
view_menu.setVisibility(View.GONE);
view_list.setVisibility(View.VISIBLE);
}
});
btn_arrow_back.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
view_list.setVisibility(View.GONE);
view_menu.setVisibility(View.VISIBLE);
}
});
}
public void setActionBarTitle(String title) {
getSupportActionBar().setTitle(title);
}
#Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
AlertDialog.Builder builder1 = new AlertDialog.Builder(MainActivity.this);
builder1.setTitle("Exit application");
builder1.setMessage("Are you sure you want to exit?");
builder1.setCancelable(true);
builder1.setPositiveButton(
"Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finish();
}
});
builder1.setNegativeButton(
"No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert11 = builder1.create();
alert11.show();
}
}
#Override
public boolean onNavigationItemSelected(#NonNull MenuItem menuItem) {
return false;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
if(toggle.onOptionsItemSelected(item)){
return true;
}
else {
return super.onOptionsItemSelected(item);
}
}
protected void initialiseData() {
//Recycler view data
mDataArray = DataHelper.getAlphabetData();
//Alphabet fast scroller data
mAlphabetItems = new ArrayList<>();
List<String> strAlphabets = new ArrayList<>();
for (int i = 0; i < mDataArray.size(); i++) {
String name = mDataArray.get(i);
if (name == null || name.trim().isEmpty())
continue;
String word = name.substring(0, 1);
if (!strAlphabets.contains(word)) {
strAlphabets.add(word);
mAlphabetItems.add(new AlphabetItem(i, word, false));
}
}
}
protected void initialiseUI() {
Typeface typeface = Typeface.createFromAsset(this.getAssets(), "font/raleway_medium.ttf");
mRecyclerView.setTypeface(typeface);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setAdapter(new VendorAdapter(mDataArray));
mRecyclerView.setIndexTextSize(14);
mRecyclerView.setIndexBarColor("#ffffff");
mRecyclerView.setIndexBarCornerRadius(0);
mRecyclerView.setIndexBarTransparentValue((float) 0.4);
mRecyclerView.setIndexbarMargin(0);
mRecyclerView.setIndexbarWidth(40);
mRecyclerView.setPreviewPadding(0);
mRecyclerView.setIndexBarTextColor("#000000");
// mRecyclerView.setPreviewTextSize(60);
// mRecyclerView.setPreviewColor("#33334c");
// mRecyclerView.setPreviewTextColor("#FFFFFF");
// mRecyclerView.setPreviewTransparentValue(0.6f);
mRecyclerView.setIndexBarVisibility(true);
mRecyclerView.setIndexbarHighLateTextColor("#000000");
mRecyclerView.setIndexBarHighLateTextVisibility(true);
}
#Override
public void setDrawerLocked(boolean shouldLock) {
if(shouldLock) {
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
toggle.setDrawerIndicatorEnabled(true);
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
else {
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
toggle.setDrawerIndicatorEnabled(false);
}
}
}
And here is the fragment code :
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.LayoutAnimationController;
import android.view.animation.TranslateAnimation;
import android.widget.TextView;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.Volley;
import com.daimajia.swipe.util.Attributes;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import static android.content.Context.MODE_PRIVATE;
public class FragmentTracking extends Fragment implements Serializable, SearchView.OnQueryTextListener, SwipeRefreshLayout.OnRefreshListener, PegawaiItemClickListener {
private final String url = "https://opensource.petra.ac.id/~m26415177/getPegawai.php";
private JsonArrayRequest request;
private RequestQueue queue;
View v;
SwipeRefreshLayout swipeLayout;
private RecyclerView mRecyclerView;
private List<ListPegawai> pegawaiList;
FloatingActionButton buttonAdd;
SwipeRecyclerViewAdapter mAdapter;
SearchView search_view_bawah;
public static final String PREFERENCES_FILE_NAME = "preference_diri";
SharedPreferences dataDiri, retrieveData;
#SuppressLint("ResourceAsColor")
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
v = inflater.inflate(R.layout.tracking_fragment,container,false);
setHasOptionsMenu(true);
retrieveData = this.getActivity().getSharedPreferences(PREFERENCES_FILE_NAME, MODE_PRIVATE);
dataDiri = this.getActivity().getSharedPreferences(PREFERENCES_FILE_NAME, MODE_PRIVATE);
SharedPreferences.Editor editor = dataDiri.edit();
//((MainActivity) getActivity()).setDrawerLocked(true);
swipeLayout = (SwipeRefreshLayout) v.findViewById(R.id.container2);
swipeLayout.setOnRefreshListener(this);
swipeLayout.setColorSchemeColors(android.R.color.holo_green_dark,
android.R.color.holo_red_dark,
android.R.color.holo_blue_dark,
android.R.color.holo_orange_dark);
mRecyclerView = (RecyclerView) v.findViewById(R.id.recyclerView);
mAdapter = new SwipeRecyclerViewAdapter(getContext(), this);
mAdapter.setMode(Attributes.Mode.Single);
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
#Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
Log.e("RecyclerView", "onScrollStateChanged");
}
#Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
}
});
pegawaiList = new ArrayList<ListPegawai>();
buttonAdd = (FloatingActionButton)v.findViewById(R.id.buttonAdd);
buttonAdd.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intentAdd = new Intent(getContext(), InsertEmployeeActivity.class);
startActivity(intentAdd);
getActivity().overridePendingTransition(R.anim.fadein,R.anim.fadeout);
getActivity().finish();
}
});
jsonRequest();
if (!isViewShown) {
animasiOn();
}
else {
}
return v;
}
private void animasiOn() {
mRecyclerView.setVisibility(View.INVISIBLE);
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(500);
set.addAnimation(animation);
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f
);
animation.setDuration(100);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
mRecyclerView.setLayoutAnimation(controller);
set.start();
mRecyclerView.setVisibility(View.VISIBLE);
}
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
pegawaiList = new ArrayList<ListPegawai>();
}
#Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.search_icon,menu);
MenuItem item = menu.findItem(R.id.search_all);
SearchView searchView = (SearchView) item.getActionView();
searchView.setOnQueryTextListener(this);
}
#Override
public boolean onQueryTextSubmit(String s) {
return false;
}
#Override
public boolean onQueryTextChange(String s) {
// String userInput = s.toLowerCase();
// List<ListPegawai> newList = new ArrayList<ListPegawai>();
//
// for(ListPegawai name:mDataSet){
// if(name.getNama().toLowerCase().contains(userInput)){
// newList.add(name);
// }
// }
//
// mAdapter.updateList(newList);
return true;
}
private boolean isViewShown = false;
#Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (getView() != null) {
isViewShown = true;
// fetchdata() contains logic to show data when page is selected mostly asynctask to fill the data
if (isVisibleToUser) {
animasiOn();
}
else {
mRecyclerView.setVisibility(View.INVISIBLE);
}
} else {
isViewShown = false;
}
}
#Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
animasiOn();
mAdapter.setPegawaiList(pegawaiList);
swipeLayout.setRefreshing(false);
pegawaiList = new ArrayList<ListPegawai>();
jsonRequest();
}
}, 750);
}
private void jsonRequest() {
request = new JsonArrayRequest(url, new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
JSONObject jsonObject = null;
for (int i = 0; i < response.length(); i++) {
try {
Log.d("LENGTH",String.valueOf(response.length()));
jsonObject = response.getJSONObject(i);
ListPegawai pegawai = new ListPegawai();
pegawai.setNama(jsonObject.getString("nama"));
pegawai.setNik(jsonObject.getString("nik"));
pegawai.setAlamat(jsonObject.getString("alamat"));
pegawai.setTanggal(jsonObject.getString("tanggal_kejadian"));
pegawai.setJenisKelamin(jsonObject.getString("jenis_kelamin"));
pegawai.setKeluhanPegawai(jsonObject.getString("keluhan"));
pegawaiList.add(pegawai);
} catch (JSONException e) {
e.printStackTrace();
}
}
setuprecyclerview(pegawaiList);
mAdapter.setPegawaiList(pegawaiList);
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
}
);
queue = Volley.newRequestQueue(getContext());
queue.add(request);
}
private void setuprecyclerview(List<ListPegawai> pegawaiList) {
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.addItemDecoration(new DividerItemDecoration(mRecyclerView.getContext(), LinearLayoutManager.VERTICAL));
mRecyclerView.setAdapter(mAdapter);
Log.d("KUDA","KUDANS");
}
#Override
public void onPegawaiItemClick(int pos, ListPegawai pegawaiList) {
}
#Override
public void onDestroyView() {
super.onDestroyView();
((MainActivity) getActivity()).setDrawerLocked(false);
}
}
When I set this code ((MainActivity) getActivity()).setDrawerLocked(true); the hamburger icon appear in all fragment. But, when I comment it, the icon not appear in all fragment
Here is the XML code, in case my mistake there :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer_layout"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main2"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout 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="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context="emptrack.toro.developer.com.emptrack.MainActivity">
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/colorPrimary"
app:tabGravity="fill"
app:tabIconTint="#FFFFFF"
app:tabIndicatorColor="#FFFFFF"
app:tabMode="fixed"
app:tabTextAppearance="#style/tab_text"
app:tabTextColor="#FFFFFF"></android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/tabLayout" />
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:paddingTop="0dp">
<include
android:id="#+id/menu_layout"
layout="#layout/list_menu" />
<include
android:id="#+id/list_vendor2"
layout="#layout/list_vendor"
android:visibility="gone" />
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
Just ask for more detailed, thanks
Just add tab Layout change listener and hide and show icon according to the requirement.
Navigation is in hidden mode, change it to visible.. it will work
i work about a vtc app and I need to display on the main screen the orders of the client.
I chose the way of customing the list view with an adapter but when i launch the app nothing on the screen except the title of the page.
i divided the adapter code and the fragment code (yeah i work in a fragment) and i want to have your opinion about my code.
Here the Fragment :
package com.cmn.cmnvtc;
import android.Manifest;
import android.app.Dialog;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.Volley;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class MainPageFragment1 extends Fragment implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener{
private LinearLayout containerView;
private TextView NoCommand;
private UserLocalStore userLocalStore;
private List<Courses> coursesList;
private ListView lvCourses;
private CoursesAdapter coursesAdapter;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_main1, container, false);
userLocalStore = new UserLocalStore(getActivity());
NoCommand = (TextView) v.findViewById(R.id.NoCommand);
lvCourses = (ListView) v.findViewById(R.id.lvCourses);
coursesList = new ArrayList<>();
final Response.Listener<String> responseListener = new Response.Listener<String>(){
#Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
boolean success = jsonObject.getBoolean("success");
if(success){
int count = jsonObject.getInt("count");
for(int i=0; i<count; i++) {
JSONObject obj = jsonObject.getJSONObject(String.valueOf(i));
String origin = obj.getString("origin");
String destination = obj.getString("destination");
String date_depart = obj.getString("date_depart");
String heure_depart = obj.getString("heure_depart");
int nb_passagers = Integer.parseInt(obj.getString("nb_passagers"));
float prix = Float.parseFloat(obj.getString("prix"));
String mode_paiement = obj.getString("paiement");
String etat_paiement = obj.getString("course_payee");
Courses course = new Courses(origin, destination, date_depart, heure_depart, nb_passagers, prix
, mode_paiement, etat_paiement);
coursesList.add(course);
}
}else{
NoCommand.setEnabled(true);
NoCommand.setText("Oups... Vous n'avez commandé aucune course pour le moment.");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
User currentUser = userLocalStore.getLoggedInUser();
final GetAllCourseRequest getAllCourse = new GetAllCourseRequest(currentUser.user_id,responseListener);
RequestQueue queue = Volley.newRequestQueue(getActivity());
queue.add(getAllCourse);
coursesAdapter = new CoursesAdapter(getActivity(), coursesList);
lvCourses.setAdapter(coursesAdapter);
lvCourses.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getActivity(), "CLicked", Toast.LENGTH_SHORT).show();
}
});
if (googleServicesAvailable()) {
containerView = (LinearLayout) v.findViewById(R.id.containerView);
askForPermission();
}
return v;
}
public boolean googleServicesAvailable() {
GoogleApiAvailability api = GoogleApiAvailability.getInstance();
int isAvaibable = api.isGooglePlayServicesAvailable(getActivity());
if (isAvaibable == ConnectionResult.SUCCESS) {
return true;
} else if (api.isUserResolvableError(isAvaibable)) {
Dialog dialog = api.getErrorDialog(getActivity(), isAvaibable, 0);
dialog.show();
} else {
Toast.makeText(getActivity(), "Can't connect to play services", Toast.LENGTH_SHORT).show();
}
return false;
}
private void explain() {
Snackbar.make(containerView, "Cette permission est nécessaire pour vous géolocalisez", Snackbar.LENGTH_LONG).setAction("Activer", new View.OnClickListener() {
#Override
public void onClick(View view) {
askForPermission();
}
}).show();
}
private void askForPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION}, 2);
}
}
#Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == 2) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (shouldShowRequestPermissionRationale(permissions[0]) == false) {
displayOptions();
} else {
explain();
}
}
if (grantResults[1] == PackageManager.PERMISSION_GRANTED) {
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (shouldShowRequestPermissionRationale(permissions[1]) == false) {
displayOptions();
} else {
explain();
}
}
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
private void displayOptions() {
Snackbar.make(containerView, "Vous avez désactivé la permission", Snackbar.LENGTH_LONG).setAction("Paramètres", new View.OnClickListener() {
#Override
public void onClick(View view) {
final Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
final Uri uri = Uri.fromParts("package", getActivity().getPackageName(), null);
intent.setData(uri);
startActivity(intent);
}
}).show();
}
#Override
public void onConnected(#Nullable Bundle bundle) {
}
#Override
public void onConnectionSuspended(int i) {
}
#Override
public void onConnectionFailed(#NonNull ConnectionResult connectionResult) {
}
}
My custom adapter :
package com.cmn.cmnvtc;
import android.content.Context;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.TextView;
import org.w3c.dom.Text;
import java.util.List;
/**
* Created by Wild Shadow on 18/06/2017.
*/
public class CoursesAdapter extends BaseAdapter {
private List<Courses> coursesList;
private Context ctx;
public CoursesAdapter(Context context, List<Courses> coursesList) {
this.ctx = context;
this.coursesList = coursesList;
}
#Override
public int getCount() {
return coursesList.size();
}
#Override
public Object getItem(int position) {
return coursesList.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = View.inflate(ctx, R.layout.row_courses, null);
TextView adrOrigin = (TextView) v.findViewById(R.id.adrOriginList);
TextView adrDestinaiton = (TextView)
v.findViewById(R.id.adrDestList);
TextView dateDepart = (TextView) v.findViewById(R.id.dateDepList);
TextView heureDepart = (TextView)
v.findViewById(R.id.heureDepList);
ImageButton viewDetails = (ImageButton)
v.findViewById(R.id.viewDetailsCourse);
adrOrigin.setText(coursesList.get(position).getOrigin());
adrDestinaiton.setText(coursesList.get(position).getDestination());
dateDepart.setText(coursesList.get(position).getDate_depart());
heureDepart.setText(coursesList.get(position).getHeure_depart());
return v;
}
}
the model layout :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="6dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_depart_courselist"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/adrOriginList"
android:textSize="17dp"
android:textColor="#000"
android:paddingTop="3dp"
android:text=" : Adresse de départ"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_destination_courselist"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/adrDestList"
android:paddingTop="3dp"
android:textColor="#000"
android:textSize="17dp"
android:text=" : Adresse d'arrivée"
android:layout_marginBottom="5dp"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_date_depart_courselist"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/dateDepList"
android:paddingTop="3dp"
android:textColor="#000"
android:textSize="17dp"
android:text=" : date de départ"
android:layout_marginBottom="3dp"
android:layout_marginRight="20dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_heure_dep_courselist"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/heureDepList"
android:paddingTop="3dp"
android:textColor="#000"
android:textSize="17dp"
android:text=" : Heure"
android:layout_marginBottom="3dp"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_details_courselist"
android:layout_marginLeft="65dp"
android:id="#+id/viewDetailsCourse"
android:paddingTop="5dp"
android:background="?android:selectableItemBackground"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
and the listview :
<ScrollView 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:paddingTop="10dp"
android:theme="#style/AppTheme"
tools:context="com.cmn.cmnvtc.MainPageFragment1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:id="#+id/TitleListCommand"
android:textSize="25dp"
android:layout_marginBottom="15dp"
android:textColor="#727574"
android:text="Liste de mes courses "/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/TitleListCommand"
android:layout_alignParentStart="true"
android:id="#+id/lvCourses"></ListView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:textColor="#969696"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:textSize="15dp"
android:textAlignment="center"
android:id="#+id/NoCommand"
android:text=""
android:enabled="false"/>
</RelativeLayout>
</ScrollView>
I hope you will help me to find the error and if you want more, try to explain me how i can optimize my code. TY
You should call notifyDataSetChanged() in the ResponseListener after filling your list.
#Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
boolean success = jsonObject.getBoolean("success");
if(success){
int count = jsonObject.getInt("count");
for(int i=0; i<count; i++) {
...
coursesList.add(course);
}
//notify adapter about change in data
coursesAdapter.notifyDataSetChanged();
}else{
NoCommand.setEnabled(true);
NoCommand.setText("Oups... Vous n'avez commandé aucune course pour le moment.");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
Actually I have done the "load from url" part but the result is not satisfying.
I wnat the image placed on the top. However, when it loaded the image, it automatically align to center but I have declared android:layout_alignParentTop="true" .
Besides, I'd like to have some text on the image but the text are always on the top left corner..........
here are my codes:
(xml)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/list_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="#+id/product_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:src="#drawable/white" />
<TextView
android:id="#+id/product_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/product_image"
android:text="#string/hello_world" />
<TextView
android:id="#+id/product_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/product_price"
android:text="#string/hello_world" />
</RelativeLayout>
activity:
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.text.Html;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;
public class PostDetail extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_detail);
getActionBar().setDisplayHomeAsUpEnabled(true);
WPTemplateDB dpOpener = new WPTemplateDB(this);
SQLiteDatabase db = dpOpener.getReadableDatabase();
//Log.d("passed pid", getIntent().getStringExtra("pid")+"");
Cursor cursor = db.query(WPTemplateDB.PRODUCT_TABLE,
new String[]{WPTemplateDB.TITLE, WPTemplateDB.IMAGE, WPTemplateDB.PRICE},
WPTemplateDB.PRODUCT_ID+"=?",
new String[]{getIntent().getStringExtra("pid")},
null, null, null);
String title = "", price = "", img = "";
while (cursor.moveToNext()){
title = cursor.getString(0);
img = cursor.getString(1);
price = cursor.getString(2);
}
Log.d("title", title);
Log.d("img_src", img);
TextView productTitle = (TextView)findViewById(R.id.product_title);
ImageView productImage = (ImageView)findViewById(R.id.product_image);
TextView productPrice = (TextView)findViewById(R.id.product_price);
new LoadImageFromURL(productImage).execute(img);
productTitle.setText(Html.fromHtml(title),TextView.BufferType.SPANNABLE);
productPrice.setText(price);
}
private class LoadImageFromURL extends AsyncTask<String, Void, Bitmap>{
ImageView bitmapImgView;
public LoadImageFromURL(ImageView bmImgView){
bitmapImgView = bmImgView;
}
#Override
protected Bitmap doInBackground(String... params) {
// TODO Auto-generated method stub
String urlStr = params[0];
Bitmap img = null;
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(urlStr);
HttpResponse response;
try {
response = (HttpResponse)client.execute(request);
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufferedEntity = new BufferedHttpEntity(entity);
InputStream inputStream = bufferedEntity.getContent();
img = BitmapFactory.decodeStream(inputStream);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return img;
}
#Override
protected void onPostExecute(Bitmap bitmap){
bitmapImgView.setImageBitmap(bitmap);
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.list_post, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
// This ID represents the Home or Up button. In the case of this
// activity, the Up button is shown. Use NavUtils to allow users
// to navigate up one level in the application structure. For
// more details, see the Navigation pattern on Android Design:
//
// http://developer.android.com/design/patterns/navigation.html#up-vs-back
//
NavUtils.navigateUpTo(this,
new Intent(this, ListPost.class));
return true;
}
return super.onOptionsItemSelected(item);
}
}
You should use wrap_content instead match_parent for product_image's android:layout_width, and you should use FrameLayout if you want put text on the ImageView. like:
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:src="#drawable/ic_launcher"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:text="test"
android:layout_height="wrap_content" />
</FrameLayout>