I have a fragment which has a bundle passed to it. The bundle come through (validated with Log tags) and the textView update within the code (I know this because the I Log getText after the TextView is supposed to be updated). My problem is that the visual representation (the screen) doesn't show the update.
numberView = (TextView) getActivity().findViewById(R.id.textView20);
//From CantactLog()
Bundle arguments = getArguments();
if ( arguments!= null) {
sName = getArguments().getString("sName");
sNumber = getArguments().getString("sNumber");
if (sNumber != null){
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
String formatedNumber = null;
try {
Phonenumber.PhoneNumber numberProto = phoneUtil.parse(sNumber, "US");
//Since you know the country you can format it as follows:
formatedNumber = phoneUtil.format(numberProto, PhoneNumberUtil.PhoneNumberFormat.NATIONAL);
} catch (NumberParseException e) {
System.err.println("NumberParseException was thrown: " + e.toString());
}
Log.i(TAG, " Formated Number " + formatedNumber);
sNumber= formatedNumber;
numberView.setText(sNumber);
// mPhoneSearch.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
scallName = sName;
Log.i(TAG, "sNumber = "+sNumber);
Log.i(TAG,"get text =" + numberView.getText().toString());
}
}
Log out put:
I/GifHeaderParser: Formated Number (650) 555-1212
I/GifHeaderParser: sNumber = (650) 555-1212
I/GifHeaderParser: get text =(650) 555-1212
Xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="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:background="#drawable/home_background"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:gravity="center"
android:orientation="vertical"
android:tag="landingFragmentTag">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/textView20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="TextView" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_marginTop="15dp"
android:orientation="horizontal">
<TextView
android:id="#+id/phoneSearch222"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="#drawable/edit_text_box"
android:ems="10"
android:hint="#string/search_by_phone_number"
android:inputType="phone"
android:lines="1"
android:maxLength="14"
android:textAlignment="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:text="Choose from Contacts" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="25dp"
android:layout_weight="1"
android:orientation="vertical">
<Spinner
android:id="#+id/call_log"
style="#android:style/Widget.DropDownItem.Spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:background="#drawable/edit_text_box"
android:minHeight="50dp"
android:spinnerMode="dialog" />
</LinearLayout>
<LinearLayout
android:id="#+id/animatedLayout"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_marginBottom="15dp"
android:layout_marginTop="15dp"
android:orientation="vertical">
<Button
android:id="#+id/PhoneSearch"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="2dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="2dp"
android:backgroundTint="#android:color/holo_orange_light"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/search_phone_number"
android:textColor="#color/cardview_dark_background"
android:visibility="visible" />
</LinearLayout>
So I answered my own question, when I was calling the fragment to open, I was using .add instead of .replace in the fragment transfer.
Related
I know this problem already asked many times but i still can't get effective way for solving this. I try for use ListView with clickable/editable widget and Android : How to set onClick event for Button in List item of ListView as reference but the result is i need click button several time for executing my program. Here my program
LeadActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".LeadSalesActivity">
<LinearLayout
android:background="#E9ECEB"
android:layout_margin="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/b_menusamping2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="20dp"
android:background="#drawable/menu_button"
android:backgroundTint="#27D01B"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome,"
android:textSize="20sp"
android:textStyle="italic"
android:textColor="#android:color/black"/>
<TextView
android:id="#+id/t_username3"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="Rizaldi"
android:textColor="#android:color/black"
android:textSize="25sp"
android:textStyle="bold"
android:fontFamily="#font/action_man_bold"/>
</LinearLayout>
<LinearLayout
android:id="#+id/linear_refresh2"
android:layout_margin="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/white">
<ImageView
android:backgroundTint="#27D01B"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="10dp"
android:background="#drawable/icon_update"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_marginLeft="20dp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lead"
android:textColor="#android:color/black"
android:textSize="20sp"/>
<TextView
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="("
android:textSize="20sp"
android:textColor="#android:color/black"/>
<TextView
android:textStyle="bold"
android:id="#+id/count_lead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="100"
android:textColor="#android:color/black"
android:textSize="20sp"/>
<TextView
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=")"
android:textSize="20sp"
android:textColor="#android:color/black"/>
<Button
android:id="#+id/btn_add"
android:layout_marginRight="20dp"
android:backgroundTint="#android:color/holo_blue_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tambah Lead"
android:textAllCaps="false"/>
</LinearLayout>
<LinearLayout
android:padding="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tanggal"
android:textColor="#android:color/black"
android:textSize="20sp"/>
<TextView
android:layout_marginLeft="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lead"
android:textSize="20sp"
android:textColor="#android:color/black"/>
<TextView
android:layout_marginLeft="40dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Telp"
android:textColor="#android:color/black"
android:textSize="20sp"/>
</LinearLayout>
<ListView
android:id="#+id/listviewlead"
tools:listitem="#layout/c_lead"
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_weight="1" />
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:id="#+id/back6"
android:layout_marginRight="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="back"/>
</LinearLayout>
c_lead.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/t_tgl"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="Tgl"
android:textSize="15sp"
android:textStyle="italic"
android:textColor="#000000" />
<TextView
android:id="#+id/t_lead4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="Lead"
android:textSize="15sp"
android:textColor="#000000" />
<TextView
android:id="#+id/t_numberphone"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:gravity="right"
android:text="No.Telp"
android:textSize="15sp"
android:textColor="#android:color/black"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<LinearLayout
android:id="#+id/btn_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/kotak_abu"
android:layout_marginTop="5dp">
<ImageButton
android:layout_margin="10dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#drawable/pencil_icon"/>
</LinearLayout>
<LinearLayout
android:id="#+id/btn_delete"
android:layout_marginLeft="3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/kotak_abu"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp">
<ImageButton
android:layout_margin="10dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#drawable/delete_icon"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/t_alamat"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="Alamat"
android:textColor="#android:color/black"
android:textSize="15sp"
android:layout_marginLeft="20dp"/>
</LinearLayout>
MyAdapter
public View getView(final int _position, View _v, ViewGroup _container) {
LayoutInflater _inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View _view = _v;
if (_view == null) {
_view = _inflater.inflate(R.layout.c_lead, null);
}
final HashMap<String, Object> hashMap = _data.get(_position);
final TextView t_tanggal = (TextView) _view.findViewById(R.id.t_tgl);
final TextView t_lead = (TextView) _view.findViewById(R.id.t_lead4);
final TextView t_alamat = (TextView) _view.findViewById(R.id.t_alamat);
final TextView t_numberphone = (TextView) _view.findViewById(R.id.t_numberphone);
final LinearLayout btn_edit = (LinearLayout) _view.findViewById(R.id.btn_edit);
final LinearLayout btn_delete = (LinearLayout) _view.findViewById(R.id.btn_delete);
String dateString = _data.get(_position).get("create_date").toString().replace("-","");
SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMddHHmm");
format1.setTimeZone(TimeZone.getTimeZone("GMT+7"));
SimpleDateFormat format2 = new SimpleDateFormat("dd-MM-yyyy");
try {
Date date = format1.parse(dateString);
String dateFinal = format2.format(date);
t_tanggal.setText(String.valueOf((long)(_position + 1)).concat(".").concat(dateFinal));
} catch (ParseException e) {
e.printStackTrace();
}
t_lead.setText(_data.get((int)_position).get("type").toString());
t_alamat.setText(_data.get((int)_position).get("street").toString());
if (_data.get((int)_position).get("mobile").toString().equals(true)){
t_numberphone.setText("Tanpa Nomor");
} else {
t_numberphone.setText(_data.get((int)_position).get("phone").toString());
}
btn_edit.setFocusable(false);
btn_edit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
i.setClass(getApplicationContext(), AddLeadSalesActivity.class);
startActivity(i);
}
});
btn_delete.setFocusable(false);
btn_delete.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "Data Tidak Bisa Dihapus", Toast.LENGTH_SHORT).show();
}
});
return _view;
}
Is there any mistake inside my program? How to solve this?
Hello Team!!
I'm new on android but i have knoweledge in html and javascript. So i have a JSON that have some options(img,or not img) and i create a recycler view to list this JSON and all ok, later i try that hide some imageView of card because the JSON show that this doesn't have picture. It works fine
But when i do scroll down to bottom limit all imageViews hide, i don't know how solve it and i search in web but i can't find some solution for this issue.
Code in adapter
#RequiresApi(api = Build.VERSION_CODES.O)
#Override
public void onBindViewHolder(postViewHolder postViewHolder, int position) {
addPostTimeline addPost = addPostTimelines.get(position);
try {
CircleImageView img=postViewHolder.imgFoto;
JSONObject fileson=addPost.getDatosTimeine().getJSONObject("file");
// postViewHolder.imgTimeLine = #+id/image_timeline
if(!fileson.getBoolean("err")){ // si tiene archivos adjuntos
switch (fileson.getString("type")){
case "Pic":
imageTimeline imgTm=new imageTimeline(fileson.getString("src"), postViewHolder.imgTimeLine);
imgTm.execute();
break;
default:
postViewHolder.imgTimeLine.setVisibility(View.GONE);
break;
}
}else{
postViewHolder.contentFiles.setVisibility(View.GONE);
}
putImgProfile putImg=new putImgProfile(addPost.getDatosTimeine().getString("pDir"), img);
putImg.execute();
} catch (JSONException e) {
e.printStackTrace();
}
}
Structure of card with recycler
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
android:id="#+id/cvManana"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
card_view:cardCornerRadius="4dp"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto">
<LinearLayout android:background="#drawable/textlines"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:orientation="vertical"
android:id="#+id/post"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imgPerfil"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginRight="8dp"
android:scaleType="centerCrop"
android:src="#mipmap/ic_load_img" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tv_fechaPost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hace 44 minutos sep. 22º 16"
android:textColor="#999" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tv_nickname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="12dp"
android:text="SonickSeven"
android:textColor="#24650e"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:id="#+id/contentTextStory">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tv_postTimeLine"
android:textColor="#666"
android:textSize="15dp"
android:layout_gravity="left"
android:text="historias"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/contentFiles">
<!-- image to hide -->
<ImageView
android:id="#+id/image_timeline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:cropToPadding="false"
android:scaleType="fitStart"
card_view:srcCompat="#drawable/campo_manana" />
<!-- end imagen to hide -->
</LinearLayout>
<LinearLayout
android:paddingTop="4dp"
android:paddingBottom="7dp"
android:layout_gravity="left"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:gravity="right"
android:layout_weight="1.0"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="#+id/bt_reply"
android:layout_gravity="center_vertical"
android:scaleType="centerCrop"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#mipmap/ic_reply_gray"/>
<TextView
android:id="#+id/countReply"
android:text="(3)"
android:textSize="12dp"
android:layout_gravity="center"
android:textColor="#999"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_weight="1.0"
android:layout_width="match_parent"
android:gravity="right"
android:layout_height="wrap_content">
<ImageButton
android:id="#+id/bt_share"
android:scaleType="centerCrop"
android:layout_gravity="center_vertical"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#mipmap/ic_share_gray"/>
<TextView
android:id="#+id/countShare"
android:text="(3)"
android:textSize="12dp"
android:layout_gravity="center"
android:textColor="#999"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_weight="1.0"
android:layout_width="match_parent"
android:gravity="right"
android:layout_height="wrap_content">
<ImageButton
android:layout_gravity="center_vertical"
android:id="#+id/bt_like"
android:scaleType="centerCrop"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#mipmap/ic_like_gray"/>
<TextView
android:id="#+id/countLike"
android:text="(3)"
android:textSize="12dp"
android:layout_gravity="center"
android:textColor="#999"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_weight="1.0"
android:layout_width="match_parent"
android:gravity="right"
android:layout_height="wrap_content">
<ImageButton
android:id="#+id/bt_dislike"
android:layout_gravity="center_vertical"
android:scaleType="centerCrop"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#mipmap/ic_nolike_gray"/>
<TextView
android:id="#+id/countNoLike"
android:text="(3)"
android:textSize="12dp"
android:layout_gravity="center"
android:textColor="#999"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
i saw that when i go to bottom of scroll and up the switch trigger again, but it doesn't could because the recycler view run all array JSON. Sorry i can understand how work android-java
Try this in onBindViewHolder method:
#RequiresApi(api = Build.VERSION_CODES.O)
#Override
public void onBindViewHolder(postViewHolder postViewHolder, int position) {
addPostTimeline addPost = addPostTimelines.get(position);
try {
CircleImageView img=postViewHolder.imgFoto;
JSONObject fileson=addPost.getDatosTimeine().getJSONObject("file");
if(!fileson.getBoolean("err") && fileson.getString("type").equals("pic")){
//image must be visible and no error
postViewHolder.imgTimeLine.setVisibility(View.VISIBLE);
postViewHolder.contentFiles.setVisibility(View.VISIBLE);
imageTimeline imgTm=new imageTimeline(fileson.getString("src"), postViewHolder.imgTimeLine);
imgTm.execute();
}else if(!fileson.getBoolean("err") && !fileson.getString("type").equals("pic")){
//image shouldn't be visible and no error
postViewHolder.imgTimeLine.setVisibility(View.GONE);
postViewHolder.contentFiles.setVisibility(View.VISIBLE);
}else{
//error
postViewHolder.imgTimeLine.setVisibility(View.GONE);
postViewHolder.contentFiles.setVisibility(View.GONE);
}
putImgProfile putImg=new putImgProfile(addPost.getDatosTimeine().getString("pDir"), img);
putImg.execute();
} catch (JSONException e) {
e.printStackTrace();
}
}
You need to reset the visible where you don’t need to set the visible.
postViewHolder.imgTimeLine.setVisibility(View.VISIBLE);// reset
if(!fileson.getBoolean("err")){ // si tiene archivos adjuntos
switch (fileson.getString("type")){
case "Pic":
imageTimeline imgTm=new imageTimeline(fileson.getString("src"),
postViewHolder.imgTimeLine);
imgTm.execute();
break;
default:
postViewHolder.imgTimeLine.setVisibility(View.GONE);
break;
}
}else{
postViewHolder.contentFiles.setVisibility(View.GONE);
}
how can I make a layout that looks like this in android using list view.
I am making a tracking system for many buses. If the bus crossed the location the circle will turn green else it is red.
I just want a vertical line which has length depending on the number of stops for the bus.
the line should be passing through the center of the circles.
Here is the listBusStops.xml file
`
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_marginBottom="30dp">
<ImageView
android:id="#+id/ivstatus"
android:layout_width="30dp"
android:layout_height="30dp"/>
<TextView
android:layout_marginStart="5dp"
android:gravity="center_vertical"
android:id="#+id/tvname"
android:layout_width="wrap_content"
android:layout_height="30dp"
/>
</TableRow>
</RelativeLayout>
`
here the custom_list class which I am using
`
class Custom_list extends ArrayAdapter {
private final Activity context;
private final Integer imageid;
ArrayList<String> list;
ArrayList<String> status;
public Custom_list(Activity context, ArrayList<String> list, ArrayList<String> status, Integer imageid) {
super(context, R.layout.list_bus_stops,Track_any_bus.stop_name);
this.context=context;
this.list = list;
this.imageid=imageid;
this.status = status;
}
public View getView (int position, View view, ViewGroup parent)
{
LayoutInflater inflater = context.getLayoutInflater();
View rowview = inflater.inflate(R.layout.list_bus_stops,null,true);// ALL LAYOUT RESOURSE OF list_bus_stops SAVED TO THIS VIEW(rowview)
TextView textView = rowview.findViewById(R.id.tvname);//
ImageView imageView = rowview.findViewById(R.id.ivstatus);
textView.setText(Track_any_bus.stop_name.get(position));
if(Track_any_bus.status.get(position).equalsIgnoreCase("yes")) {
imageView.setImageResource(R.drawable.circle_green);
}
else {
imageView.setImageResource(R.drawable.circle_red);
}
return rowview;
}
`
thank you for your time.
Here is the demo working code plz have a look i hope it will help you
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:id="#+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:scrollingCache="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="18dp"
android:layout_marginStart="18dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="#D3D3D3" />
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginTop="44dp"
android:tint="#000000"
app:srcCompat="#drawable/shape_round_solid" />
</RelativeLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="1dp"
app:cardCornerRadius="5dp"
app:cardElevation="12dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:background="#ffff"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:background="#800000"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:layout_height="1dp"></LinearLayout>
<TextView
android:id="#+id/noteTitle"
android:textColor="#ffffff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Title"
android:background="#000000 "
android:textSize="20dp" />
<LinearLayout
android:layout_width="match_parent"
android:background="#800000"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:layout_height="1dp"></LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:textSize="14dp"
android:textColor="#000080"
android:text="Text-Preview"/>
<TextView
android:id="#+id/textPreview"
android:textSize="14dp"
android:textColor="#000080"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="5dp"
android:text="Sample Text"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_height="wrap_content"
android:textSize="14dp"
android:textColor="#000080"
android:layout_marginLeft="18dp"
android:layout_width="120dp"
android:text="Last Modified"/>
<TextView
android:id="#+id/lastModified"
android:textColor="#000080"
android:layout_width="wrap_content"
android:textSize="14dp"
android:layout_marginLeft="50dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginTop="5dp"
android:text="12/4/2018"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
I have 2 fragments, and want to do a shared element transition between them.
The item in an recyclerview, with an adapter, contains a textview that should be animated to an edittext in the next fragment.
The recyclerview is in an fragment too.
Here's my code:
item layout for viewholder from adapter:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/row_container"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="#FAFAFA"
android:elevation="0dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackground"
android:elevation="0dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:elevation="0dp"
>
<RelativeLayout
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#null"
android:elevation="0dp"
android:layout_centerVertical="true"
>
<ImageButton
android:id="#+id/notify_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_bookmark_black_24dp"
android:background="#null"
android:tint="#9E9E9E"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginRight="20dp"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="#android:color/black"
android:layout_alignParentTop="true"
android:maxLines="1"
android:ellipsize="end"
android:transitionName="title"
/>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/text"
android:layout_below="#id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginRight="20dp"
android:textSize="15sp"
android:maxLines="2"
android:layout_alignParentBottom="true"
android:textColor="#android:color/black"
android:ellipsize="end"
android:transitionName="text"
/>
</RelativeLayout>
<ImageView
android:id="#+id/fav"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:visibility="invisible"
android:src="#drawable/ic_star_black_24dp"
/>
</RelativeLayout>
MyAdapter class, the item row click:
row.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Fragment frag = new Fragment_Notice();
int tin_title = Integer.parseInt(String.valueOf(title.getText().length()));
if ( (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) &&
( SharedPrefHelper.getBool("shared_transition") == true) &&
( tin_title >= 1 ) ) {
//Exit transition for old fragment
frag.setSharedElementReturnTransition(TransitionInflater.from(context).inflateTransition(R.transition.title_transform));
frag.setExitTransition(TransitionInflater.from(context).inflateTransition(android.R.transition.explode));
//Enter transition for new fragment
frag.setSharedElementEnterTransition(TransitionInflater.from(context).inflateTransition(R.transition.title_transform));
frag.setEnterTransition(TransitionInflater.from(context).inflateTransition(android.R.transition.explode));
ft.replace(R.id.container, frag, "NoticeTag")
.addToBackStack(null)
.addSharedElement(title, "title")
.commit();
} else {
int open = R.anim.abc_fade_in;
int close = R.anim.abc_fade_out;
ft.setCustomAnimations(open, close, open, close)
.replace(R.id.container, frag, "NoticeTag")
.addToBackStack(null)
.commit();
}
}
});
Layout from final fragment:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:padding="10dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<EditText
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:nextFocusForward="#id/text"
android:imeOptions="actionNext"
android:singleLine="true"
android:ems="16"
android:hint="#string/title"
android:textColor="#212121"
android:textColorHint="#757575"
android:background="#null"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:scrollbars="horizontal"
android:transitionName="title"
/>
<EditText
android:id="#+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/text"
android:textColor="#212121"
android:textColorHint="#757575"
android:background="#null"
android:layout_marginLeft="2dp"
android:transitionName="text"
/>
<View
android:id="#+id/line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:elevation="0dp"
android:background="#color/grey"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
>
<ImageButton
android:id="#+id/fav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_star_black_24dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:padding="5dp"
android:background="?android:attr/selectableItemBackground"
android:tint="#9E9E9E"
/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="top"
android:id="#+id/snackbar">
</android.support.design.widget.CoordinatorLayout>
The textview doesnt animate to an edittext.
The explode animation appears.
Between activities the animation works.
Any suggestions how to fix?
I need to make the image that I get from database circular
I have made this code but I don't know how to complete it to make the image circular
please help
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
name = (TextView) findViewById(R.id.names);
date = (TextView) findViewById(R.id.dates);
Story = (TextView) findViewById(R.id.story);
im = (ImageView) findViewById(R.id.img_car);
im.setScaleType(ImageView.ScaleType.FIT_XY);
//ScrollView scroller = new ScrollView(this);
//scroller.addView(Story);
Bundle extras = getIntent().getExtras();
int idf = extras.getInt("index");
Book selectedBook;
db = new SQLhelper(getApplicationContext());
// read the book with "id" from the database
selectedBook = db.readBook(++idf);
name.setText(selectedBook.getTitle());
date.setText(selectedBook.getdate());
Story.setText(selectedBook.getstory()+"\n \n ");
pname = selectedBook.getTitle();
test = selectedBook.getimage();
int id = getResources().getIdentifier("com.example.tarekhy:drawable/" + test, null, null);
im.setImageResource(id);
}
and this is xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp"
android:background="#drawable/customborder">
<ImageView
android:id="#+id/img_car"
android:layout_width="70dp"
android:layout_height="50dp"
android:layout_marginBottom="5dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:contentDescription="#null"
android:gravity="center_vertical"
android:onClick="viewbig"
/>
<RelativeLayout
android:id="#+id/imgs"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<LinearLayout
android:id="#+id/layout_car_model"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal" >
<TextView
android:id="#+id/names"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:text="gfhbj"/>
</LinearLayout>
<LinearLayout
android:id="#+id/layout_car_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/layout_car_model"
android:orientation="horizontal" >
<TextView
android:id="#+id/dates"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="italic"
/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<ScrollView android:id="#+id/textAreaScroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_x="0px"
android:layout_y="25px"
android:scrollbars="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_below="#+id/fbedittext"
android:layout_marginTop="22dp"
android:id="#+id/story"
android:textStyle="bold"
android:layout_marginBottom="20px"
/>
</ScrollView>
"
</LinearLayout>
I think that I need to make a style
I tried to do this but I failed
Help please
You Need CircularImageView From CircularImageView
in xml file You have To Replace this code instead of Imageview :-<de.hdodenhof.circleimageview.CircleImageView
android:id ="#+id/img_car"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_centerInParent="true"
app:border_width="2dp"
app:border_color="#color/dark" />
In Activity File Replace This Code instead of Imageview:-
CircleImageView im= (CircleImageView) findViewById(R.id.img_car);