0
passieren, wie der Titel sagt, ich bin versucht, die Hintergrundfarbe mit intentPutExtra zu setzen, aber es tut sich ändern scheinen, das ist meine Absicht, aus dem MainActivity:Der Versuch, eine Hintergrundfarbe durch intentPutExtra
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position == 0) {
Intent intent = new Intent(MainActivity.this, ktmList.class);
intent.putExtra("backgroundColor", getResources().getColor(R.color.colorOrange));
startActivity(intent);
}
und diese
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.models_list);
Intent intent = new Intent();
int backgroundColor = intent.getIntExtra("backgroundColor", -1);
LinearLayout rootView = (LinearLayout)findViewById(R.id.models_rootView);
rootView.setBackgroundColor(backgroundColor);
und dies ist die models_list xML-Datei:
<?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:id="@+id/models_rootView"
android:orientation="vertical">
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/models_list"
android:padding="16dp"/>
</LinearLayout>
ist, wie ich versuche, die Hintergrundfarbe zu ändern 210
Vielen Dank für jede Art von Hilfe!
jetzt meine App abstürzt gearbeitet, als ich mit java das Array klicken. lang.RuntimeException: Es konnte kein a gestartet werden ctivity ComponentInfo {com.ofir.motinfo/com.ofir.motoinfo.brandlists.ktmList}: android.content.res.Resources $ NotFoundException: Ressourcen ID # 0xffffffff – Skity
check edits .... –
Immer noch den gleichen Fehler, vielleicht die Problem ist in meinem intent.getIntExtra ("backgroundColor", -1) ;? erstes Mal mit Extras, ist dies der richtige Weg? – Skity