I created markers on the map. When I click on them, the custom info windows are always as wide as the screen.
I tried setting layout_width="200dp" but that didn't help. I also tried setting
view.setLayoutParams(new LayoutParams(GetDipsFromPixel(200), GetDipsFromPixel(300)));
I can set the width of the textviews by setting snippetUi.setWidth(GetDipsFromPixel(200)); but the layout still remains screen wide.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#FFFFFF"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:padding="10dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FFFFFF"
android:gravity="center_vertical">
<ImageView
android:id="#+id/worldmap_infowindow_profileimg"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/noimage" />
<TextView
android:id="#+id/worldmap_infowindow_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="To do No.2."
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold"
android:paddingLeft="5dp"/>
</LinearLayout>
<View android:id="#+id/separator"
android:background="#ababab"
android:layout_width = "fill_parent"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:layout_height="1dp"/>
<TextView
android:id="#+id/worldmap_infowindow_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="See the Giza Pyramids"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/worldmap_infowindow_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="It was fascinating! It's a shame that it was raining, though."
android:textColor="#000000"
android:textSize="14sp"
android:textStyle="normal" />
</LinearLayout>
Class:
private class CustomInfoWindowAdapter implements InfoWindowAdapter {
private View view;
public CustomInfoWindowAdapter() {
view = getLayoutInflater().inflate(R.layout.custom_infowindow, null);
}
#Override
public View getInfoContents(Marker marker) {
if (WorldMap.this.myMarker != null
&& WorldMap.this.myMarker.isInfoWindowShown()) {
WorldMap.this.myMarker.hideInfoWindow();
WorldMap.this.myMarker.showInfoWindow();
}
return null;
}
#Override
public View getInfoWindow(final Marker marker) {
WorldMap.this.myMarker = marker;
final String title = marker.getTitle();
final TextView titleUi = ((TextView) view.findViewById(R.id.worldmap_infowindow_name));
if (title != null) {
titleUi.setText(title);
} else {
titleUi.setText("");
}
final String snippet = marker.getSnippet();
final TextView snippetUi = ((TextView) view.findViewById(R.id.worldmap_infowindow_details));
if (snippet != null) {
snippetUi.setText(snippet);
} else {
snippetUi.setText("");
}
return view;
}
}
Basically you just need to have another level of layout below root, like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:background="#android:color/transparent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="250dp"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="horizontal">
...
Just create the parent layout with "wrap_content" and a child layout with the desired size:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- This layout defines the desired size -->
<LinearLayout
android:layout_width="240dp"
android:layout_height="320dp"
android:orientation="vertical">
<!-- Your views here -->
</LinearLayout>
</LinearLayout>
If you want to show custom window with fixed size ( Height or Width ) then you have to make drawable and set it as a background of XML.
I have posted my answer HERE with solution.You can refer how it works.
#Override
public View getInfoWindow(Marker arg0) {
return null;
}
#Override
public View getInfoContents(Marker arg0) {
View v = getActivity().getLayoutInflater().inflate(R.layout.custom_info_window, null);
v.setLayoutParams(new LinearLayout.LayoutParams(500,300));
}
In my case, I set the fixed width of one of the child of the layout and it worked. Don't know why it did not work when setting width of the root view. Here is an example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="vertical"
android:padding="3dp">
<ImageView
android:id="#+id/info_window_image"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="#drawable/facebook"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:text="Free for All Soccer Game"
android:textColor="#color/blue"
android:textSize="#dimen/medium" />
</LinearLayout
>
Related
I have created a custom ListView with 2 ImageView and a TextView.
In the Adapter, I'm doing setText in TextView, but it is not visible in the app.
Here is my List:
<?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="match_parent"
android:background="#ffffff">
<View
android:layout_width="fill_parent"
android:layout_height="5dp"
android:background="#289FA5"/>
<RelativeLayout
android:layout_marginTop="7dp"
android:layout_marginLeft="7dp"
android:layout_marginBottom="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#289FA5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Popular products"
android:textSize="23sp"
android:padding="7dp"/>
</RelativeLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="120dp">
<LinearLayout
android:id="#+id/pop_pro_men"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
<RelativeLayout
android:layout_marginTop="15dp"
android:layout_marginLeft="7dp"
android:layout_marginBottom="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#289FA5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Catagories"
android:textSize="23sp"
android:padding="7dp"/>
</RelativeLayout>
<ListView
android:id="#+id/cata_men"
android:layout_width="fill_parent"
android:layout_height="wrap_content"></ListView>
Here is my Custom List:
<LinearLayout
android:id="#+id/custom_list"
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:background="#ffffff">
<ImageView
android:layout_gravity="left"
android:id="#+id/imageView2"
android:layout_height="130dp"
android:layout_marginLeft="7dp"
android:layout_width="120dp"
android:src="#drawable/clothing_men"/>
<TextView
android:id="#+id/cata_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clothing"
android:layout_marginTop="35dp"
android:textStyle="bold"
android:textSize="27sp"
android:padding="10dp"
android:layout_weight="1"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/forward_arrow"
android:layout_marginTop="42dp"/>
And Here is the getView method of my Adapter:
public View getView(final int position, View convertView, ViewGroup parent) {
final Holder holder = new Holder();
View rowView;
rowView = inflater.inflate(R.layout.custom_subcatagory_list, null,true);
TextView sub_catagory= (TextView) rowView.findViewById(R.id.cata_name);
ImageView pic = (ImageView) rowView.findViewById(R.id.imageView2);
sub_catagory.setText(catagory[position]);
pic.setImageResource(image[position]);
Log.d("Strings========", sub_catagory.getText().toString());
rowView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(context, "You Clicked " + catagory[position], Toast.LENGTH_LONG).show();
}
});
return rowView;
}
Please Help as i am unable to find what is wrong in this.
Remove your layout_weight attribute from your TextView. If you remove sub_catagory.setText(catagory[position]); does "Clothing" appear when you run your app?
I got the answer now. I don't know how my textColor was set to White, because i didn't mentioned it. So, change the color to something else and it worked.And it wasted my whole day.
Sorry to disturb you all.
Need to click only one layout out of 2 relative layouts, but when I click any - both gets selected. How can I select particular view?
Please find screenshot:
Java code
final ViewGroup footer = (ViewGroup) inflater.inflate(R.layout.footer,
mDrawerList, false);
mTxtAddLeague = (TextView) footer.findViewById(R.id.add_league);
mTxtLogout = (TextView) footer.findViewById(R.id.logout);
mDrawerList.addFooterView(footer, null, true);
mTxtAddLeague.setOnClickListener(this);
mTxtLogout.setOnClickListener(this);
// Add League text click
public void onClick(View v) {
if(v.getId() == R.id.logout) {
//
}
else if(v.getId() == R.id.add_league) {
mTxtAddLeague.setTypeface(null, Typeface.BOLD);
}
}
Here is my footer.xml file
<?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">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/drawer_item_height">
<View
android:layout_width="match_parent"
android:layout_height="#dimen/view_height"
android:background="#color/hints" />
<ImageView
android:id="#+id/image_child"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="#dimen/drawer_left_parent_image"
android:src="#drawable/editp" />
<TextView
android:id="#+id/add_league"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:ellipsize="end"
android:paddingLeft="#dimen/drawer_left_parent_text"
android:text="#string/add_league"
android:textSize="#dimen/text_size" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/drawer_item_height">
<View
android:layout_width="match_parent"
android:layout_height="#dimen/view_height"
android:background="#color/hints" />
<ImageView
android:id="#+id/image_child_second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="#dimen/drawer_left_parent_image"
android:src="#drawable/editp" />
<TextView
android:id="#+id/logout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:ellipsize="end"
android:paddingLeft="#dimen/drawer_left_parent_text"
android:text="#string/logout"
android:textSize="#dimen/text_size" />
</RelativeLayout>
</LinearLayout>
How can I select particular view?
I'm developing a Chat App, so I create a list of friends.
Take a look at my ListView declaration at layout.xml
<ListView
android:listSelector="#android:color/transparent"
android:id="#+id/usersList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:background="#android:color/transparent"
android:cacheColorHint="#android:color/transparent"
android:divider="#android:color/transparent"
android:dividerPadding="2dp"
android:overScrollFooter="#null"
android:scrollingCache="false"
android:transcriptMode="normal"
/>
And the behavior of this ListView is annoying.
When I run my app in a phone with Android 2.3 the TextView itens of my ListView becomes transparent just like the image below:
Sometimes when a press the itens the color of TextView back to normality.
When I run my app in a phone with Android 4.1 this problem not happens.
My user item xml:
<?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:background="#android:color/white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="5dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_gravity="center"
android:layout_margin="5dp"
android:adjustViewBounds="true"
android:src="#drawable/quick_blox_user" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="vertical" >
<TextView
android:cacheColorHint="#android:color/transparent"
android:id="#+id/text_view_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="asdasdad"
android:textColor="#color/text_gray"
android:textSize="25sp" />
<TextView
android:cacheColorHint="#android:color/transparent"
android:id="#+id/text_view_user_last_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="asdasdad"
android:textColor="#color/text_gray_light"
android:textSize="12sp" />
<LinearLayout
android:id="#+id/layout_pending_messages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/button_message_pending_number"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#color/color_new_message_title"
android:padding="2dp"
android:text="12"
android:textColor="#android:color/white"
android:textSize="24sp" />
<TextView
android:id="#+id/text_view_user_last_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:text="#string/pending_messages"
android:textColor="#color/color_new_message"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
My Adapter:
public class UserAdapter extends BaseCustomAdapter<UserItem> {
public UserAdapter(Activity a, List<UserItem> d) {
super(a, d);
}
#Override
public View getView(int position, View view, ViewGroup parent) {
if(view == null) {
view = LayoutInflater.from(activity).inflate( R.layout.user_quickblox_item, null);
}
UserItem user = data.get(position);
String userLogin = user.getUser().getLogin();
int index = userLogin.indexOf("#");
if(index != -1) {
userLogin = userLogin.substring(0, index);
}
int count = ChatMessageDAO.getInstance(activity).countMessagePendentBySenderId(user.getUser().getId());
View viewPendingMessages = view.findViewById(R.id.layout_pending_messages);
if(count == 0) {
viewPendingMessages.setVisibility(View.GONE);
} else {
viewPendingMessages.setVisibility(View.VISIBLE);
Button buttonMessageNumberIndicator = (Button)view.findViewById(R.id.button_message_pending_number);
buttonMessageNumberIndicator.setText(String.valueOf(count));
}
TextView textViewUser = (TextView)view.findViewById(R.id.text_view_user);
textViewUser.setText(userLogin);
TextView textViewUserLastActivity = (TextView)view.findViewById(R.id.text_view_user_last_activity);
long diff = new Date().getTime() - user.getUser().getLastRequestAt().getTime();
long diffInDays = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
if(diffInDays == 0) {
long diffInHours = TimeUnit.HOURS.convert(diff, TimeUnit.MILLISECONDS);
if(diffInHours == 0) {
long diffInMinutes = TimeUnit.MINUTES.convert(diff, TimeUnit.MILLISECONDS);
if(diffInMinutes < 0) {
textViewUserLastActivity.setText("Esta online agora");
} else {
textViewUserLastActivity.setText("Entrou hoje " + diffInMinutes+ " minuto(s) atrás");
}
} else {
textViewUserLastActivity.setText("Entrou hoje " + diffInHours+ " horas atrás");
}
} else if(diffInDays == 1) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(user.getUser().getLastRequestAt());
int hour = calendar.get(Calendar.HOUR_OF_DAY);
textViewUserLastActivity.setText("Entrou ontem as " + hour + " horas");
} else {
textViewUserLastActivity.setText("Entrou " + diffInDays + " dia(s) atras");
}
return view;
}
}
How to avoid this problem?
There is a chance that the TextViews are not showing at all. not the colour is changing. you can check that by setting a background for the textviews.
A few mistakes in the item xml I would like to point out:
You have two items in the horizontal layout. the linear layout that contains the image and the linear layout that contains textview. In this case you can't have them both match_parent. the total size would be screen size * 2.
when setting weight for a linear layout in a horizontal container you set the width to 0dp.
your weight sum is 1 + 0.5 = 1.5. means that the image will reserve 2/3 of screen size and textview 1/3. looks un-logical.
These un logical values could cause different layout display for different os version.
Solution:
<?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:background="#android:color/white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="5dp" >
<LinearLayout
**android:layout_width="0dp"**
android:layout_height="match_parent"
**android:layout_weight="1"**
android:orientation="vertical" >
<ImageView
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_gravity="center"
android:layout_margin="5dp"
android:adjustViewBounds="true"
android:src="#drawable/quick_blox_user" />
</LinearLayout>
<LinearLayout
**android:layout_width="0dp"**
android:layout_height="match_parent"
**android:layout_weight="2"**
android:orientation="vertical" >
<TextView
android:cacheColorHint="#android:color/transparent"
android:id="#+id/text_view_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="asdasdad"
android:textColor="#color/text_gray"
android:textSize="25sp" />
<TextView
android:cacheColorHint="#android:color/transparent"
android:id="#+id/text_view_user_last_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="asdasdad"
android:textColor="#color/text_gray_light"
android:textSize="12sp" />
<LinearLayout
android:id="#+id/layout_pending_messages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/button_message_pending_number"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#color/color_new_message_title"
android:padding="2dp"
android:text="12"
android:textColor="#android:color/white"
android:textSize="24sp" />
<TextView
android:id="#+id/text_view_user_last_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:text="#string/pending_messages"
android:textColor="#color/color_new_message"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
What solved my problem was android:background:
<LinearLayout
android:background="#android:color/white
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:cacheColorHint="#android:color/transparent"
android:id="#+id/text_view_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="asdasdad"
android:textColor="#color/text_gray"
android:textSize="25sp" />
<TextView
android:cacheColorHint="#android:color/transparent"
android:id="#+id/text_view_user_last_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="asdasdad"
android:textColor="#color/text_gray_light"
android:textSize="12sp" />
At my LinearLayout which has the TextViews at my user_item.xml(The layout of itens of the List). I put background color as White. Its strange because the main ViewGroup of this layout is already set with background color White. Now My itens appears normally.
An Annoying solution for an Annoying problem.
I implemented one layout to use on popup of map marker (Maps V2), but I cant configure my layout as I need.
In the image bellow, you can see that the popup with informations about the marker have a white border, I need remove it. I neet fill the popup background with yellow (as the center box).
What is wrong in my layout xml?
My XML (info_window_map)
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/pastel" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#color/blue_nightsky"
android:orientation="horizontal"
>
<TextView
android:id="#+id/linha_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Linha "
android:textColor="#color/white"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:id="#+id/cod_linha"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:textColor="#color/white"
android:textSize="13sp"
android:layout_gravity="left"
android:layout_marginLeft="5dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/onibus_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ônibus....: "
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/cod_onibus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/previsao_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Previsão..: "
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/previsao"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
My Adapter (that use the xml)
class MyInfoWindowAdapter implements InfoWindowAdapter{
private final View myContentsView;
MyInfoWindowAdapter(){
myContentsView = getLayoutInflater().inflate(R.layout.info_window_map, null);
}
#Override
public View getInfoContents(Marker marker) {
//Seta a linha no infowindow
TextView txtTitle = ((TextView)myContentsView.findViewById(R.id.cod_linha));
txtTitle.setText(marker.getTitle());
//Pega a informação em snippet e separa linha, codOnibus do endereço
String snippet = marker.getSnippet();
Snippet snp = new Snippet();
snp.fillSnippet(snippet);
TextView txtCodLinha = ((TextView)myContentsView.findViewById(R.id.cod_linha));
txtCodLinha.setText(snp.getLinha());
TextView txtCodOnibus = ((TextView)myContentsView.findViewById(R.id.cod_onibus));
txtCodOnibus.setText(snp.getCodOnibus());
TextView txtPrevisao = ((TextView)myContentsView.findViewById(R.id.previsao));
txtPrevisao.setText(snp.getPrevisao());
return myContentsView;
}
#Override
public View getInfoWindow(Marker marker) {
// TODO Auto-generated method stub
return null;
}
}
There is quite strange and bad error on devices from sony family.
I have implemented actually the same code as it was in example.
There is a problem with dialog layout which show very very strange behaviour.
So far I don't know how to fix it.
Here is the picture:
Here is my code:
public class DialogFragmentRadioChannelAdd extends DialogFragment {
private DialogInterface.OnClickListener listener;
private AddChannelListener addChannelListener;
public DialogFragmentRadioChannelAdd() {
setDialogType(DialogType.AlertDialog);
}
#Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater inflater = LayoutInflater.from(getActivity());
View dialoglayout = inflater.inflate(R.layout.add_channel, null);
final EditText channelAddTitle = (EditText) dialoglayout.findViewById(R.id.addChannelTitle);
final EditText channelAddUrl = (EditText) dialoglayout.findViewById(R.id.addChannelUrl);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(("Dodaj kanał radiowy"));
builder.setView(dialoglayout);
builder.setPositiveButton("Zapisz", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
if (addChannelListener != null)
addChannelListener.onSave(dialogInterface, i, channelAddTitle, channelAddUrl);
}
})
.setNegativeButton("Anuluj", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
if (addChannelListener != null)
addChannelListener.onCancel(dialogInterface, i);
}
});
return builder.create();
}
public void setAddChannelListener(AddChannelListener addChannelListener)
{
this.addChannelListener = addChannelListener;
}
}
And here is the xml code:
<?xml version="1.0" encoding="utf-8"?>
<org.holoeverywhere.widget.LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="1dp"
android:layout_margin="1dp"
>
<org.holoeverywhere.widget.EditText
android:id="#+id/addChannelTitle"
android:minWidth="250dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="Wpisz tytuł kanału radiowego"/>
<org.holoeverywhere.widget.EditText
android:id="#+id/addChannelUrl"
android:layout_below="#id/addChannelTitle"
android:minWidth="250dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="Wpisz adres url kanału radiowego"/>
</org.holoeverywhere.widget.LinearLayout>
Someone was talking to replace linearlayout with something else in root but I don't have so much experience to find out the solution. As I said the problem is usualy with sony family in android 2.3.+
Edit:
So I spend some time to find out any hack.
Here is a link to show what did I changed (hosted on diff comparator 1year)(or the right comparing to original code on the left) Link to compartor with changes.
What I did is just changing linear layout into relative in base holoeverywhere layout called alert_dialog_holo.xml found in holoeverywhere library in res/layout
Fixed alert_dialog.xml layout for version holoeverywhere (dont know but today is 22-12-2013 so I think it is 2.1.0)
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:layout_height="wrap_content"
android:id="#+id/parentPanel"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/topPanel"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="2dip"
android:id="#+id/titleDividerTop"
android:background="#color/holo_blue_light"
android:visibility="gone" />
<LinearLayout
android:layout_below="#+id/titleDividerTop"
android:layout_width="match_parent"
android:layout_marginRight="16dip"
android:layout_marginLeft="16dip"
android:gravity="center_vertical|left"
android:minHeight="#dimen/alert_dialog_title_height"
android:layout_height="wrap_content"
android:id="#+id/title_template"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:paddingRight="8dip"
android:layout_height="wrap_content"
android:id="#+id/icon"
android:contentDescription="#string/loading"></ImageView>
<Internal.DialogTitle
android:layout_width="match_parent"
style="?android:windowTitleStyle"
android:ellipsize="end"
android:singleLine="true"
android:layout_height="wrap_content"
android:id="#+id/alertTitle"></Internal.DialogTitle>
</LinearLayout>
<View
android:layout_below="#+id/title_template"
android:layout_width="match_parent"
android:layout_height="2dip"
android:id="#+id/titleDivider"
android:background="?alertDialogTitleDividerColor"
android:visibility="gone"></View>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/contentPanel"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:clipToPadding="false"
android:layout_height="wrap_content"
android:id="#+id/scrollView">
<TextView
android:layout_width="match_parent"
style="?android:attr/textAppearanceMedium"
android:paddingBottom="8dip"
android:paddingLeft="16dip"
android:paddingRight="16dip"
android:layout_height="wrap_content"
android:paddingTop="8dip"
android:id="#+id/message" />
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:layout_below="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/customPanel">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/custom"></FrameLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:minHeight="#dimen/alert_dialog_button_bar_height"
android:layout_height="wrap_content"
android:id="#+id/buttonPanel"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="#+id/buttonPanelTopDivivder"
android:background="?dividerHorizontal" />
<LinearLayout
android:layout_width="match_parent"
style="?buttonBarStyle"
android:measureWithLargestChild="true"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_gravity="left"
style="?buttonBarButtonStyle"
android:minHeight="#dimen/alert_dialog_button_bar_height"
android:textSize="14sp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/button2"
android:maxLines="2"></Button>
<Button
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
style="?buttonBarButtonStyle"
android:minHeight="#dimen/alert_dialog_button_bar_height"
android:textSize="14sp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/button3"
android:maxLines="2"></Button>
<Button
android:layout_width="wrap_content"
android:layout_gravity="right"
style="?buttonBarButtonStyle"
android:minHeight="#dimen/alert_dialog_button_bar_height"
android:textSize="14sp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/button1"
android:maxLines="2"></Button>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
You will get some errors in library's code but you need just to change it to relative where is linear
I am talking about class AlertController.java also stored in holoeverywhere libary in /src/widget/.
For listview/singlechoicemenu in dialog and according to up xml you need change some code in AlertController in method setupContent(xxx)
private void setupContent(RelativeLayout contentPanel) {
mScrollView = (ScrollView) mWindow.findViewById(R.id.scrollView);
mScrollView.setFocusable(false);
mMessageView = (TextView) mWindow.findViewById(R.id.message);
if (mMessageView == null) {
return;
}
if (mMessage != null) {
mMessageView.setText(mMessage);
} else {
mMessageView.setVisibility(View.GONE);
mScrollView.removeView(mMessageView);
if (mListView != null) {
contentPanel.removeView(mWindow.findViewById(R.id.scrollView));
contentPanel.addView(mListView, new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
contentPanel.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
} else {
contentPanel.setVisibility(View.GONE);
}
}
}