[Q] ListView with BaseAdapter not showing - Java for Android App Development

Hi I have used ListFragment and simple ArrayAdapter quite often. And now I want to try some more by customizing BaseAdapter. But something happened, the List is not showing at all. I don't have any error (the Logcat also saying there're no error). But I debug it, and found out that getView() in my customized BaseAdapter is not called. I wonder why?
Here's the snippet:
#favorite_list_layout
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ListView
android:id="@+id/favorite_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
#favorite_list_item
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/favorite_text"
android:layout_margin="5dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="0dp"
android:textSize="35sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/favorite_text_details"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="5dp"
android:fontFamily="sans-serif-light"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
#FavoritesFragment
Code:
public class FavoritesFragment extends ListFragment {
[user=439709]@override[/user]
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
//... setting variable favList, and this code is working. favList is not empty and there're no error
setListAdapter(new FavoriteAdapter(getActivity(), favList));
}
}
FavoriteAdapter, extends BaseAdapter
Code:
public class FavoriteAdapter extends BaseAdapter {
private Context ctx;
List<DMapData> list;
public FavoriteAdapter(Context context, List<DMapData> list) {
this.ctx = context;
this.list = list;
System.out.println("constructor executed!");
}
[user=439709]@override[/user]
public int getCount() {
return list.size();
}
[user=439709]@override[/user]
public Object getItem(int i) {
return list.get(i);
}
[user=439709]@override[/user]
public long getItemId(int i) {
return i;
}
[user=439709]@override[/user]
public View getView(int position, View convertView, ViewGroup parent) {
System.out.println("GetView is executed"); //But it's not.
View rowView = convertView;
if (rowView == null) {
LayoutInflater inflater = (LayoutInflater) ctx
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView = inflater.inflate(R.layout.favorite_list_item, parent, false);
}
TextView favText = (TextView) rowView.findViewById(R.id.favorite_text);
TextView detailsText = (TextView) rowView.findViewById(R.id.favorite_text_details);
DMapData data = list.get(position);
System.out.println("DMapData from List");
favText.setText(data.getName());
detailsText.setText(data.getDetails().length()<=50? data.getDetails() : data.getDetails().substring(0, 51).concat("..."));
System.out.println("At the end of getView()");
return rowView;
}
}
Thanks

The id of the ListView has to be a special one so that the ListFragment can find it:
Code:
android:id="@android:id/list"

Hmm...
I have tried to change the id like your code. But, still not shown up. Is there anything I should do with my ListFragment?
nikwen said:
The id of the ListView has to be a special one so that the ListFragment can find it:
Code:
android:id="@android:id/list"
Click to expand...
Click to collapse

JoshieGeek said:
Hmm...
I have tried to change the id like your code. But, still not shown up. Is there anything I should do with my ListFragment?
Click to expand...
Click to collapse
Do you inflate your layout?
Code:
[user=439709]@override[/user]
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_layout, container, false);
}
I always set the adapter in onCreate but there shouldn't be a difference.
Your layout looks like that now, right?
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ListView
android:id="android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
EDIT: Oh, add an orientation to the LinearLayout or replace it by a RelativeLayout.
And change the ListView heigth to match_parent.

Yupz. But still no different.
Here's my changed code. I have changed not using my customized adapter again, but instead using SimpleAdapter.
/res/layout/favorite_list_layout.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
/res/layout/favorite_list_item
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/favorite_text"
android:layout_margin="5dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="0dp"
android:textSize="35sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/favorite_text_details"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="5dp"
android:fontFamily="sans-serif-light"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
/src/.../AllFragment.java
Code:
public class AllFragment extends ListFragment {
[user=439709]@override[/user]
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//TODO get All Data
//Let's just adopt Favorite List Adapter for now
MasterDataReader mdReader = new MasterDataReader();
mdReader.execute();
List<DMapData> allList = new ArrayList<DMapData>();
allList.add(new DMapData("Empty", "No data found!"));
try {
allList = mdReader.get();
System.out.println("All List received");
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
List<Map<String, String>> finList = new ArrayList<Map<String, String>>();
for(DMapData data : allList) {
Map<String, String> m = new HashMap<String, String>();
m.put("name", data.getName());
m.put("detail", data.getDetails().length()<=50? data.getDetails() : data.getDetails().substring(0, 51).concat("..."));
finList.add(m);
}
String[] colNames = new String[] {
"name", "detail"
};
int[] tView = new int[] {
R.id.favorite_text, R.id.favorite_text_details
};
SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(), finList, R.layout.favorite_list_layout,
colNames, tView);
setListAdapter(simpleAdapter);
}
[user=439709]@override[/user]
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.favorite_list_layout, container, false);
}
}
What do you think?
nikwen said:
Do you inflate your layout?
Code:
[user=439709]@override[/user]
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_layout, container, false);
}
I always set the adapter in onCreate but there shouldn't be a difference.
Your layout looks like that now, right?
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ListView
android:id="android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
EDIT: Oh, add an orientation to the LinearLayout or replace it by a RelativeLayout.
And change the ListView heigth to match_parent.
Click to expand...
Click to collapse

JoshieGeek said:
Yupz. But still no different.
Here's my changed code. I have changed not using my customized adapter again, but instead using SimpleAdapter.
/res/layout/favorite_list_layout.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
/res/layout/favorite_list_item
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/favorite_text"
android:layout_margin="5dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="0dp"
android:textSize="35sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/favorite_text_details"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="5dp"
android:fontFamily="sans-serif-light"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
/src/.../AllFragment.java
Code:
public class AllFragment extends ListFragment {
[user=439709]@override[/user]
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//TODO get All Data
//Let's just adopt Favorite List Adapter for now
MasterDataReader mdReader = new MasterDataReader();
mdReader.execute();
List<DMapData> allList = new ArrayList<DMapData>();
allList.add(new DMapData("Empty", "No data found!"));
try {
allList = mdReader.get();
System.out.println("All List received");
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
List<Map<String, String>> finList = new ArrayList<Map<String, String>>();
for(DMapData data : allList) {
Map<String, String> m = new HashMap<String, String>();
m.put("name", data.getName());
m.put("detail", data.getDetails().length()<=50? data.getDetails() : data.getDetails().substring(0, 51).concat("..."));
finList.add(m);
}
String[] colNames = new String[] {
"name", "detail"
};
int[] tView = new int[] {
R.id.favorite_text, R.id.favorite_text_details
};
SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(), finList, R.layout.favorite_list_layout,
colNames, tView);
setListAdapter(simpleAdapter);
}
[user=439709]@override[/user]
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.favorite_list_layout, container, false);
}
}
What do you think?
Click to expand...
Click to collapse
Try this layout:
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/list"
android:layout_alignParentTop="true"
android:fastScrollEnabled="true" />
<ProgressBar
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
style="?android:attr/progressBarStyle" />
</RelativeLayout>
It's working for me.
Did you try to write all entries to the logs? Do you get an output?

You know what? This is really make me laugh all the time, that it's because what I think is right but actually not. The list that I provided for my ListView is actually empty. Your layout tell me, because there's always the progressbar. Thank you very much for your help. :highfive:
nikwen said:
Try this layout:
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/list"
android:layout_alignParentTop="true"
android:fastScrollEnabled="true" />
<ProgressBar
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
style="?android:attr/progressBarStyle" />
</RelativeLayout>
It's working for me.
Did you try to write all entries to the logs? Do you get an output?
Click to expand...
Click to collapse

JoshieGeek said:
You know what? This is really make me laugh all the time, that it's because what I think is right but actually not. The list that I provided for my ListView is actually empty. Your layout tell me, because there's always the progressbar. Thank you very much for your help. :highfive:
Click to expand...
Click to collapse
Welcome.
I'm glad that you solved that because it began to drive me crazy. :laugh:

@JoshieGeek
consider using Log
Log.i("class/functionName","message you want to display");
Click to expand...
Click to collapse
It will be easy to debug

Sandeep_Jagtap said:
@JoshieGeek
consider using Log
It will be easy to debug
Click to expand...
Click to collapse
Didn't you see that he already solved his problem?

nikwen said:
Didn't you see that he already solved his problem?
Click to expand...
Click to collapse
Yes its quite noticeable
As he was saying he could not see error in Log while debugging. My advice to use log was for his future projects.
Sent from my Incredible S using xda app-developers app

Sandeep_Jagtap said:
Yes its quite noticeable
As he was saying he could not see error in Log while debugging. My advice to use log was for his future projects.
Sent from my Incredible S using xda app-developers app
Click to expand...
Click to collapse
OK.
Check out my guide on debugging here: http://forum.xda-developers.com/showthread.php?t=2325164

Related

[Q] ArrayAdapter and custom layout

Hi , i'm studyng android Adapter
I want create a ListView with a serie of data. Ok , the code.
Code:
/*
Activity class
*/
package it.actiondesign.android.app.userdata;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
public class UserDataActivity extends Activity {
ArrayList<UserData> allUsers = new ArrayList<UserData>();
private ListView myListView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myListView= (ListView) findViewById(R.id.datalist);
createFakeData();
int resID = R.layout.user_row;
// data_adpater = new ArrayAdapter<UserData>(this, R.layout.user_row, allUsers);
// myListView.setAdapter(data_adpater);
}
//fill ArrayList with fake data
private void createFakeData() {
UserData first = new UserData("Frank", "Smith", 30, "Chicaco");
UserData second = new UserData("Tania", "Roger", 20, "Los Angeles");
allUsers.add(first);
allUsers.add(second);
}
}
here the main.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/datalist"></ListView>
</LinearLayout>
I create a class of data
Code:
public class UserData {
private String name;
private String surname;
private int age;
private String from;
public UserData(String _name , String _surname, int _age, String _from){
this.name= _name;
this.surname= _surname;
this.age= _age;
this.from= _from;
}
public String getName(){
return name;
}
public String getSurname(){
return surname;
}
public int getAge(){
return age;
}
public String getFrom(){
return from;
}
}
custom layout of a single item
Code:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow android:id="@+id/TableRow01" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="Name: "
android:id="@+id/TextView01" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView android:text=""
android:id="@+id/tName" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="@color/red">
</TextView>
</TableRow>
<TableRow android:id="@+id/TableRow02" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="Surname: "
android:id="@+id/TextView02" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView android:text=""
android:id="@+id/tSurname" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="@color/red">
</TextView>
</TableRow>
<TableRow android:id="@+id/TableRow03" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="From: "
android:id="@+id/TextView03" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView android:text=""
android:id="@+id/tFrom" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="@color/red">
</TextView>
</TableRow>
<TableRow android:id="@+id/TableRow04" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="Age: "
android:id="@+id/TextView03" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView android:text=""
android:id="@+id/tAge" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="@color/red">
</TextView>
</TableRow>
</TableLayout>
In other layout a create a ArrayAdpater<String> and all was simple, but how can fill TextView (tName, tSurname, tAge, tFrom) with data.
Now I use a simple ArrayList after i load data from WebService
Depends what kind of data your are retrieving. In your layout you have 4 textview 'rows'. Maybe instead of this you could use a listview?

Widget not working

Hey, fellas.. I was learning about widgets. But I got stuck at the very beginning. I was trying to make the simplest of a widget. Firstly, I made an app, that only has one textview on it. When clicked , it shows the number of times it has been clicked. Then I tried to make a widget of the same.
But when I click over the widget, nothing happens. It just shows the initialized number '0'. The debugging goes fine. There is no ANR errors.
But I am not able to figure out the logical error. As the debugging goes alright, I don't think, the logcat will be necessary.
However, If required , I will provide it too. For now, I am uploading the AppWidget.class, widget.xml, manifest.xml, widget_provider.xml :::
THE APPWIDGET.CLASS:
Code:
package com.example.increment;
import android.app.IntentService;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;
public class AppWidget extends AppWidgetProvider {
int c = 0;
[user=439709]@override[/user]
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if (intent.getAction() == null)
context.startService(new Intent(context, ToggleService.class));
else
super.onReceive(context, intent);
}
[user=439709]@override[/user]
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
// TODO Auto-generated method stub
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
private class ToggleService extends IntentService {
public ToggleService() {
super("AppWidget$ToggleService");
// TODO Auto-generated constructor stub
}
[user=439709]@override[/user]
protected void onHandleIntent(Intent intent) {
// TODO Auto-generated method stub
ComponentName me = new ComponentName(this, AppWidget.class);
AppWidgetManager mgr = AppWidgetManager.getInstance(this);
mgr.updateAppWidget(me, buildUpdate(this));
}
private RemoteViews buildUpdate(Context context) {
// TODO Auto-generated method stub
RemoteViews rm = new RemoteViews(context.getPackageName(),
R.layout.widget);
c++;
String s = String.valueOf(c);
rm.setTextViewText(R.id.t2, s);
Intent i = new Intent(this, AppWidget.class);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
rm.setOnClickPendingIntent(R.id.t2, pi);
return rm;
}
}
}
THE WIDGET.XML
Code:
<?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" >
<TextView
android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:clickable="true" />
</LinearLayout>
THE WIDGET_PROVIDER.XML:
Code:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minHeight="100sp"
android:minWidth="100sp"
android:updatePeriodMillis="1000"
android:initialLayout="@layout/widget">
</appwidget-provider>
THE MANIFEST.XML:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.increment"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.increment.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="com.example.increment.AppWidget"
android:icon="@drawable/ic_launcher"
android:label="tanmay" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_provider" />
</receiver>
<service android:name=".AppWidget$ToggleService" >
</service>
</application>
</manifest>
Thanks in advance..

2.3.3 to 4.2.2 Http Get - Help me conquer learning curve

Hey all!
New to Android but not developing. App runs great with emulator running Android 2.3.3. When I install the app to my phone (Samsung Galaxy 4S Active) runnnig Android 4.2.2, the Http Get execute command on the client does not seem to happen. I get no data back reported to my TextView.
I know there is some learning curve I'm missing here, and would appreciate some guidance.
HttpExample.java
Code:
package com.example.test;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HttpExample extends Activity {
TextView httpStuff;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.httpex);
httpStuff = (TextView) findViewById(R.id.tvHttp);
GetMethodEx test = new GetMethodEx();
try {
String returned = test.getInternetData();
httpStuff.setText(returned);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
GetMethodEx.java
Code:
package com.example.test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
public class GetMethodEx {
public String getInternetData () throws Exception {
BufferedReader in = null;
String data = null;
try {
HttpClient client = new DefaultHttpClient();
URI website = new URI("CANTPOSTURL");
HttpGet request = new HttpGet();
request.setURI(website);
HttpResponse response = client.execute(request);
in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String l = "";
String nl = System.getProperty("line.separator");
while ((l = in.readLine()) !=null) {
sb.append(l + nl);
}
in.close();
data = sb.toString();
return data;
}finally {
if (in !=null) {
try {
in.close();
return data;
}catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
AndroidManifest.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="CANTPOSTURL"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.test.HttpExample"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
httpex.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="CANTPOSTURL"
xmlns:tools="CANTPOSTURL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".HttpActivity">
<ScrollView android:layout_height="fill_parent" android:layout_width="fill_parent">
<TextView
android:id="@+id/tvHttp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Loading Data" >
</TextView>
</ScrollView>
</LinearLayout>
I would post the logcat but there really is no issue at 2.3.3... just need to know what i'm missing going to 4.2.2.
Thanks in advance, I know this should be easy for you all.

[Q] How can custom tab view be implemented using setCustomTabView method

I am using Android's SlidingTabColors sample in my application layout. I have three tabs initialized. Due to the default tab layout all the tabs have same layout. I have searched everything about setCustomTabView; but unable to get it implemented. I wanted to know where should i call this method? What statements are to be used? I have used a switch statement in the onViewCreated method of the ContentFragment class. The code I have written in the onViewCreated method is posted below:
Code:
public void onViewCreated(View view, Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
TextView title = (TextView) view.findViewById(R.id.item_title);
int indicatorColor = args.getInt(KEY_INDICATOR_COLOR);
switch (indicatorColor)
{
case Color.RED:
{
SlidingTabLayout mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
mSlidingTabLayout.setCustomTabView(R.layout.speed_test, R.id.hello1);
}
case Color.GREEN:
title.setText("Subject: " + args.getCharSequence(KEY_TITLE));
case Color.BLUE:
title.setText("Header: " + args.getCharSequence(KEY_TITLE));
}
}
[CODE]
The speed_test.xml file is posted below:
[CODE]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello"
android:id="@+id/hello1"
/>
</RelativeLayout>
[CODE]

[Q] My aplication is shuting down by no reason

Hello ! I left my eclipse for a few days, after that my aplicaton for no reason is working bad. First Activity is opening as well, but aplication is closing when first activity is opening second. I was searching mistakes or errors in code but i have nothing. Below i paste code of first activity and second. Please help.
First Activity:
Code:
public class Pierwsza extends ActionBarActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pierwszy);
getSupportActionBar().hide();
Thread welcomeThread = new Thread()
{
@Override
public void run() {
try {
super.run();
sleep(3000) ; //Delay of 10 seconds
} catch (Exception e) {
} finally {
Intent i = new Intent(Pierwsza.this,
MainActivity.class);
startActivity(i);
finish();
}
}
};
welcomeThread.start();
}
}
second:
Code:
public class MainActivity extends ActionBarActivity {
ArrayAdapter<String> dataAdapter = null;
ArrayList<String> elementy = new ArrayList<String>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();
ListaPiosenek();
powiadomienie();
}
private void ListaPiosenek() {
ArrayList<String> elementy = new ArrayList<String>();
elementy.add("Dom w górach");
elementy.add("Jedyne co mam");
elementy.add("Koncert");
elementy.add("Ocean");
elementy.add("Tolerancja");
elementy.add("Wiesiek idzie");
elementy.add("Wiosna, ach to ty");
elementy.add("Chłopaki nie płaczą");
elementy.add("Dziki Włóczęga");
elementy.add("Imperatyw");
elementy.add("Piosenka Turystyczna III");
elementy.add("Remedium");
elementy.add("Kiedy będę starą kobietą");
elementy.add("Długość dźwięku samotności");
elementy.add("Król");
elementy.add("Anna");
elementy.add("Syn Miasta");
elementy.add("Samotna fregata");
elementy.add("Balonik");
elementy.add("Partyzant");
elementy.add("O mój rozmarynie");
elementy.add("Sosenka");;
// elementy.add("Długość dźwięku samotności");
// elementy.add("Długość dźwięku samotności");
// elementy.add("Długość dźwięku samotności");
// elementy.add("Długość dźwięku samotności");
// elementy.add("Długość dźwięku samotności");
Collections.sort(elementy);
final ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,R.layout.single_row,elementy);
final ListView list=(ListView)findViewById(R.id.listView1);
list.setAdapter(dataAdapter);
list.setFocusableInTouchMode(true);
list.requestFocus();
list.setTextFilterEnabled(true);
EditText myFilter =(EditText)findViewById(R.id.editText1);
myFilter.addTextChangedListener(new TextWatcher(){
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
dataAdapter.getFilter().filter(s.toString());
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
}
private void powiadomienie() {
ListView list = (ListView)findViewById(R.id.listView1);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View viewClicked,
int position, long id) {
String sText = ((TextView) viewClicked).getText().toString();
if(sText.equals("Dom w górach")){
Intent i = new Intent(MainActivity.this,Utwor0.class);
startActivity(i);
overridePendingTransition(R.animator.animation1, R.animator.animation2);
}
else if(sText.equals("Jedyne co mam")){
Intent i = new Intent(MainActivity.this, Utwor1.class);
startActivity(i);
}
else if(sText.equals("Koncert")){
Intent i = new Intent(MainActivity.this, Utwor2.class);
startActivity(i);
}
else if(sText.equals("Ocean")){
Intent i = new Intent(MainActivity.this, Utwor3.class);
startActivity(i);
}
else if(sText.equals("Tolerancja")){
Intent i = new Intent(MainActivity.this, Utwor4.class);
startActivity(i);
}
else if (sText.equals("Wiesiek idzie")){
Intent i = new Intent(MainActivity.this, Utwor5.class);
startActivity(i);
}
else if(sText.equals("Wiosna, ach to ty")){
Intent i = new Intent(MainActivity.this, Utwor6.class);
startActivity(i);
}
else if(sText.equals("Chłopaki nie płaczą")){
Intent i = new Intent(MainActivity.this, Utwor7.class);
startActivity(i);
}
else if(sText.equals("Dziki Włóczęga")){
Intent i = new Intent(MainActivity.this, Utwor8.class);
startActivity(i);
}
else if(sText.equals("Imperatyw")){
Intent i = new Intent(MainActivity.this, Utwor9.class);
startActivity(i);
}
else if(sText.equals("Piosenka Turystyczna III")){
Intent i = new Intent(MainActivity.this, Utwor10.class);
startActivity(i);
}
else if(sText.equals("Remedium")){
Intent i = new Intent(MainActivity.this, Utwor11.class);
startActivity(i);
}
else if(sText.equals("Kiedy będę starą kobietą")){
Intent i = new Intent(MainActivity.this, Utwor12.class);
startActivity(i);
}
else if(sText.equals("Długość dźwięku samotności")){
Intent i = new Intent(MainActivity.this, Utwor13.class);
startActivity(i);
}
else if(sText.equals("Król")){
Intent i = new Intent(MainActivity.this, Utwor14.class);
startActivity(i);
}
else if(sText.equals("Anna")){
Intent i = new Intent(MainActivity.this, Utwor15.class);
startActivity(i);
}
else if(sText.equals("Syn Miasta")){
Intent i = new Intent(MainActivity.this, Utwor16.class);
startActivity(i);
}
else if(sText.equals("Samotna fregata")){
Intent i = new Intent(MainActivity.this, Utwor17.class);
startActivity(i);
}
else if(sText.equals("Balonik")){
Intent i = new Intent(MainActivity.this, Utwor18.class);
startActivity(i);
}
else if(sText.equals("Partyzant")){
Intent i = new Intent(MainActivity.this, Utwor19.class);
startActivity(i);
}
else if(sText.equals("O mój rozmarynie")){
Intent i = new Intent(MainActivity.this, Utwor20.class);
startActivity(i);
}
else if(sText.equals("Sosenka")){
Intent i = new Intent(MainActivity.this, Utwor21.class);
startActivity(i);
}
}
});
}
}
Eclipse is not showing red errors in code.
Matma said:
Hello ! I left my eclipse for a few days, after that my aplicaton for no reason is working bad. First Activity is opening as well, but aplication is closing when first activity is opening second. I was searching mistakes or errors in code but i have nothing. Below i paste code of first activity and second. Please help.
First Activity:
Code:
public class Pierwsza extends ActionBarActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pierwszy);
getSupportActionBar().hide();
Thread welcomeThread = new Thread()
{
@Override
public void run() {
try {
super.run();
sleep(3000) ; //Delay of 10 seconds
} catch (Exception e) {
} finally {
Intent i = new Intent(Pierwsza.this,
MainActivity.class);
startActivity(i);
finish();
}
}
};
welcomeThread.start();
}
}
second:
Code:
public class MainActivity extends ActionBarActivity {
ArrayAdapter<String> dataAdapter = null;
ArrayList<String> elementy = new ArrayList<String>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();
ListaPiosenek();
powiadomienie();
}
private void ListaPiosenek() {
ArrayList<String> elementy = new ArrayList<String>();
elementy.add("Dom w górach");
elementy.add("Jedyne co mam");
elementy.add("Koncert");
elementy.add("Ocean");
elementy.add("Tolerancja");
elementy.add("Wiesiek idzie");
elementy.add("Wiosna, ach to ty");
elementy.add("Chłopaki nie płaczą");
elementy.add("Dziki Włóczęga");
elementy.add("Imperatyw");
elementy.add("Piosenka Turystyczna III");
elementy.add("Remedium");
elementy.add("Kiedy będę starą kobietą");
elementy.add("Długość dźwięku samotności");
elementy.add("Król");
elementy.add("Anna");
elementy.add("Syn Miasta");
elementy.add("Samotna fregata");
elementy.add("Balonik");
elementy.add("Partyzant");
elementy.add("O mój rozmarynie");
elementy.add("Sosenka");;
//elementy.add("Długość dźwięku samotności");
//elementy.add("Długość dźwięku samotności");
//elementy.add("Długość dźwięku samotności");
//elementy.add("Długość dźwięku samotności");
//elementy.add("Długość dźwięku samotności");
Collections.sort(elementy);
final ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,R.layout.single_row,elementy);
final ListView list=(ListView)findViewById(R.id.listView1);
list.setAdapter(dataAdapter);
list.setFocusableInTouchMode(true);
list.requestFocus();
list.setTextFilterEnabled(true);
EditText myFilter =(EditText)findViewById(R.id.editText1);
myFilter.addTextChangedListener(new TextWatcher(){
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
dataAdapter.getFilter().filter(s.toString());
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
}
private void powiadomienie() {
ListView list = (ListView)findViewById(R.id.listView1);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View viewClicked,
int position, long id) {
String sText = ((TextView) viewClicked).getText().toString();
if(sText.equals("Dom w górach")){
Intent i = new Intent(MainActivity.this,Utwor0.class);
startActivity(i);
overridePendingTransition(R.animator.animation1, R.animator.animation2);
}
else if(sText.equals("Jedyne co mam")){
Intent i = new Intent(MainActivity.this, Utwor1.class);
startActivity(i);
}
else if(sText.equals("Koncert")){
Intent i = new Intent(MainActivity.this, Utwor2.class);
startActivity(i);
}
else if(sText.equals("Ocean")){
Intent i = new Intent(MainActivity.this, Utwor3.class);
startActivity(i);
}
else if(sText.equals("Tolerancja")){
Intent i = new Intent(MainActivity.this, Utwor4.class);
startActivity(i);
}
else if (sText.equals("Wiesiek idzie")){
Intent i = new Intent(MainActivity.this, Utwor5.class);
startActivity(i);
}
else if(sText.equals("Wiosna, ach to ty")){
Intent i = new Intent(MainActivity.this, Utwor6.class);
startActivity(i);
}
else if(sText.equals("Chłopaki nie płaczą")){
Intent i = new Intent(MainActivity.this, Utwor7.class);
startActivity(i);
}
else if(sText.equals("Dziki Włóczęga")){
Intent i = new Intent(MainActivity.this, Utwor8.class);
startActivity(i);
}
else if(sText.equals("Imperatyw")){
Intent i = new Intent(MainActivity.this, Utwor9.class);
startActivity(i);
}
else if(sText.equals("Piosenka Turystyczna III")){
Intent i = new Intent(MainActivity.this, Utwor10.class);
startActivity(i);
}
else if(sText.equals("Remedium")){
Intent i = new Intent(MainActivity.this, Utwor11.class);
startActivity(i);
}
else if(sText.equals("Kiedy będę starą kobietą")){
Intent i = new Intent(MainActivity.this, Utwor12.class);
startActivity(i);
}
else if(sText.equals("Długość dźwięku samotności")){
Intent i = new Intent(MainActivity.this, Utwor13.class);
startActivity(i);
}
else if(sText.equals("Król")){
Intent i = new Intent(MainActivity.this, Utwor14.class);
startActivity(i);
}
else if(sText.equals("Anna")){
Intent i = new Intent(MainActivity.this, Utwor15.class);
startActivity(i);
}
else if(sText.equals("Syn Miasta")){
Intent i = new Intent(MainActivity.this, Utwor16.class);
startActivity(i);
}
else if(sText.equals("Samotna fregata")){
Intent i = new Intent(MainActivity.this, Utwor17.class);
startActivity(i);
}
else if(sText.equals("Balonik")){
Intent i = new Intent(MainActivity.this, Utwor18.class);
startActivity(i);
}
else if(sText.equals("Partyzant")){
Intent i = new Intent(MainActivity.this, Utwor19.class);
startActivity(i);
}
else if(sText.equals("O mój rozmarynie")){
Intent i = new Intent(MainActivity.this, Utwor20.class);
startActivity(i);
}
else if(sText.equals("Sosenka")){
Intent i = new Intent(MainActivity.this, Utwor21.class);
startActivity(i);
}
}
});
}
}
Eclipse is not showing red errors in code.
Click to expand...
Click to collapse
Is log showing something?
Gesendet von meinem LG-D855 mit Tapatalk
FATAL EXCEPTION: main
java.lang.OutOfMemoryError
E/AndroidRuntime(882): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
E/AndroidRuntime(882): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
E/AndroidRuntime(882): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
E/AndroidRuntime(882): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
E/AndroidRuntime(882): at android.content.res.Resources.loadDrawable(Resources.java:1965)
E/AndroidRuntime(882): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
E/AndroidRuntime(882): at android.view.View.<init>(View.java:3330)
E/AndroidRuntime(882): at android.widget.TextView.<init>(TextView.java:583)
E/AndroidRuntime(882): at android.widget.EditText.<init>(EditText.java:60)
E/AndroidRuntime(882): at android.support.v7.internal.widget.TintEditText.<init>(TintEditText.java:44)
E/AndroidRuntime(882): at android.support.v7.internal.widget.TintEditText.<init>(TintEditText.java:40)
E/AndroidRuntime(882): at android.support.v7.app.ActionBarActivityDelegateBase.createView(ActionBarActivityDelegateBase.java:759)
E/AndroidRuntime(882): at android.support.v7.app.ActionBarActivity.onCreateView(ActionBarActivity.java:552)
E/AndroidRuntime(882): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
E/AndroidRuntime(882): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
E/AndroidRuntime(882): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
E/AndroidRuntime(882): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
E/AndroidRuntime(882): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
at com.example.another.MainActivity.onCreate(MainActivity.java:29)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
E/AndroidRuntime(882): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
E/AndroidRuntime(882): at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime(882): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime(882): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(882): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(882): at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime(882): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(882): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(882): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime(882): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime(882): at dalvik.system.NativeStart.main(Native Method)
Matma said:
FATAL EXCEPTION: main
java.lang.OutOfMemoryError
E/AndroidRuntime(882): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
E/AndroidRuntime(882): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
E/AndroidRuntime(882): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
E/AndroidRuntime(882): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
E/AndroidRuntime(882): at android.content.res.Resources.loadDrawable(Resources.java:1965)
E/AndroidRuntime(882): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
E/AndroidRuntime(882): at android.view.View.(View.java:3330)
E/AndroidRuntime(882): at android.widget.TextView.(TextView.java:583)
E/AndroidRuntime(882): at android.widget.EditText.(EditText.java:60)
E/AndroidRuntime(882): at android.support.v7.internal.widget.TintEditText.(TintEditText.java:44)
E/AndroidRuntime(882): at android.support.v7.internal.widget.TintEditText.(TintEditText.java:40)
E/AndroidRuntime(882): at android.support.v7.app.ActionBarActivityDelegateBase.createView(ActionBarActivityDelegateBase.java:759)
E/AndroidRuntime(882): at android.support.v7.app.ActionBarActivity.onCreateView(ActionBarActivity.java:552)
E/AndroidRuntime(882): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
E/AndroidRuntime(882): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
E/AndroidRuntime(882): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
E/AndroidRuntime(882): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
E/AndroidRuntime(882): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
at com.example.another.MainActivity.onCreate(MainActivity.java:29)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
E/AndroidRuntime(882): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
E/AndroidRuntime(882): at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime(882): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime(882): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(882): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(882): at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime(882): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(882): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(882): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime(882): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime(882): at dalvik.system.NativeStart.main(Native Method)
Click to expand...
Click to collapse
It looks like there is an error in MainActivity line 29, could you please tell me which one that is so that we can better analyze it?
From looking at the stacktrace, there is probably an error concerning one of your layouts, as it says that "setContentView" has a problem. (I have marked those lines in the stacktrace in red)
--------------------
Phone: Nexus 4
OS: rooted Lollipop LRX21T
Bootloader: unlocked
Recovery: TWRP 2.8.2.0
29 line in Main Activity (second Activity in my first post) its
"private void ListaPiosenek()" and i dont know what i can change ;/
here is XML file (Activity Main layout)
Code:
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.another.MainActivity" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/horizontalScrollView1"
android:layout_below="@+id/editText1"
android:background="@drawable/tlo4"
android:descendantFocusability="beforeDescendants"
android:dividerHeight="2dp"
android:drawSelectorOnTop="true"
android:smoothScrollbar="true"
android:visibility="visible" >
</ListView>
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/listView1"
android:layout_alignParentBottom="true"
android:smoothScrollbar="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="79dp"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/a" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/a7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/am" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxWidth="70dp"
android:scaleType="centerInside"
android:src="@drawable/am7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/a6" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/amaj7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/asus" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/b" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/b6" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/b7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/bm" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/bm7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/bmaj7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/bsus" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/c" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/c7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/cm" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/cmaj7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/csus" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/d" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/d6" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/d7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/dm" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/dm7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/dmaj7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/e" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/e6" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/e7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/em" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/em7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/f" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/f6" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/f7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/fm" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/fmaj7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/fsus" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/g" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/g6" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/g7" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/g9" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/gmaj7" />
</LinearLayout>
</HorizontalScrollView>
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignBottom="@+id/imageView1"
android:layout_alignTop="@+id/imageView1"
android:layout_toRightOf="@+id/imageView1"
android:background="@drawable/szukajtlo"
android:ems="10"
android:hint="Szukaj" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/listView1"
android:layout_alignParentTop="true"
android:layout_marginBottom="20sp"
android:src="@drawable/logo144" />
</RelativeLayout>
I think your issue comes from too many / too big bitmaps loaded at the same time.
Before trying to use Bitmap.recycle() ar change bitmap configure, can you check that this is your issue removing some widgets witgh bitmaps?
Can you also test by removing hardware acceleration using this:
android:hardwareAccelerated="false"
Ecrou said:
I think your issue comes from too many / too big bitmaps loaded at the same time.
Before trying to use Bitmap.recycle() ar change bitmap configure, can you check that this is your issue removing some widgets witgh bitmaps?
Can you also test by removing hardware acceleration using this:
android:hardwareAccelerated="false"
Click to expand...
Click to collapse
I will try but tell me why its not working like this, cause it was, and i have working aplication on my phone :x ?
Oh i see now, you have a huge lot of image views inside your layout, this is too memory heavy. I would recommend using a listview where one item consists of a single imageview. Like that, there are always just a few images being loaded at once and the others are recycled. This is far more memory friendly
And i cant really imagine this could have ever worked nicely before, so i wonder how you could have run your app before..
--------------------
Phone: Nexus 4
OS: rooted Lollipop LRX21T
Bootloader: unlocked
Recovery: TWRP 2.8.2.0
Masrepus said:
Oh i see now, you have a huge lot of image views inside your layout, this is too memory heavy. I would recommend using a listview where one item consists of a single imageview. Like that, there are always just a few images being loaded at once and the others are recycled. This is far more memory friendly
And i cant really imagine this could have ever worked nicely before, so i wonder how you could have run your app before..
--------------------
Phone: Nexus 4
OS: rooted Lollipop LRX21T
Bootloader: unlocked
Recovery: TWRP 2.8.2.0
Click to expand...
Click to collapse
Its still working with that many imageViews on my phone, but i think i will delete it and make another Activty and Layout, thank you guys for help .
Matma said:
Its still working with that many imageViews on my phone, but i think i will delete it and make another Activty and Layout, thank you guys for help .
Click to expand...
Click to collapse
Yeah it depends on the device's ram and the heap settings if it crashes or not. But rather be safe than sorry
--------------------
Phone: Nexus 4
OS: rooted Lollipop LRX21T
Bootloader: unlocked
Recovery: TWRP 2.8.2.0

Categories

Resources