私は新しいユーザーであり、Androidプログラマーの初心者です。MainActivity.javaにコードを記述しましたが、これは仮想デバイスでは機能しませんが、その理由はわかりません。なぜそれが機能しないのか誰か教えてもらえますか?前もって感謝します
package com.tee.contactsList;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;
public class MainActivity extends Activity
{
LinearLayout mainLayout;
TextView title;
TextView contact1;
ScrollView scrollList;
LinearLayout list;
TabHost tabs;
TabSpec firstTab;
TabSpec secondTab;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tabs = new TabHost(this);
firstTab = tabs.newTabSpec("tid1");
secondTab = tabs.newTabSpec("tid2");
mainLayout = new LinearLayout(this);
title = new TextView(this);
contact1 = new TextView(this);
scrollList = new ScrollView(this);
list = new LinearLayout(this);
tabs.addTab(firstTab);
tabs.addTab(secondTab);
firstTab.setIndicator("Contacts");
secondTab.setIndicator("Calender");
tabs.getTabWidget().setCurrentTab(1);
mainLayout.setId(123);
mainLayout.setOrientation(LinearLayout.VERTICAL);
list.setOrientation(LinearLayout.VERTICAL);
mainLayout.addView(title);
title.setText("Contacts");
mainLayout.addView(scrollList);
scrollList.addView(list);
scrollList.setBackgroundColor(0x0000ff00);
list.setBackgroundColor(0x0000ff00);
contact1.setBackgroundColor(0x0000ff00);
list.addView(contact1);
String s="\n";
String array[]={"contact1","contact2","contact3","contact4","contact5"};
for (int x=0;x<=4;x++)
{
s+="contact";
s+=(x+1);
s+=":";
s+=array[x];
s+="\n";
}
contact1.setText(s);
firstTab.setContent(123);
setContentView(tabs);
}
}