ScrollView can host only one direct child

282 views
Skip to first unread message

Éderson Sandre

unread,
Aug 14, 2015, 11:29:59 AM8/14/15
to Android Brasil - Dev
Boa tarde galera!


Estou tendo dificuldade ao rodar aplicativo em um nova activity, ao criar um nova esta em apresentando o seguinte erro:

java.lang.RuntimeException: Unable to start activity ComponentInfo
Caused by: java.lang.IllegalStateException: ScrollView can host only one direct child

Sendo que nesta nova activity não tem ligação nenhuma com as outras do aplicativo, está no padrão que o sistema me gera de criação.


Éderson Sandre

Thiago Neves

unread,
Aug 14, 2015, 12:16:48 PM8/14/15
to Android Brasil - Dev
Provavelmente nessa Activity que você está chamando deve ter mais de um view como Filho, e só pode ter um filho direto, entendeu ?



--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Éderson Sandre

unread,
Aug 14, 2015, 12:36:10 PM8/14/15
to androidb...@googlegroups.com
Então Thiago, o duro que não!


public class RegisterActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_register, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
}

Adiel Cristo

unread,
Aug 14, 2015, 12:51:24 PM8/14/15
to androidb...@googlegroups.com
Olá Éderson,

Faltou o layout, activity_register.

Atte.,

Adiel Cristo
Mobile Application Developer / Web Developer

Éderson Sandre

unread,
Aug 14, 2015, 12:52:53 PM8/14/15
to androidb...@googlegroups.com
Adiel tem o layout:

<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.tapago.android.apps.usuario.RegisterActivity"
style="@style/TaPagoUsuario"
>

<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</RelativeLayout>

--

Adiel Cristo

unread,
Aug 14, 2015, 1:10:59 PM8/14/15
to androidb...@googlegroups.com
Man, manda o stack trace
Não cheguei a criar um projeto pra testar, mas pelo q entendi esse erro pode estar ocorrendo em outra activity.
Você pode ter adicionado a view novamente em algum outro trecho do código (em outra activity).

Atte.,

Adiel Cristo
Mobile Application Developer / Web Developer

Éderson Sandre

unread,
Aug 14, 2015, 3:06:07 PM8/14/15
to androidb...@googlegroups.com
Galera deu certo... o problema estava em um outra activity que esta montada errada... o Adiel me ajudou a debugar!

Você são fera!!! :D
Reply all
Reply to author
Forward
0 new messages