1

最初,我只有 1 个基本页面,其中不包含任何tablayout内容,并且运行良好。插入的数据已通过套接字。

现在,我正在使用tablayout,它不传递数据。发生了什么?

这是我的活动,包括套接字:

commandline = commandline + "[" + id+"]";

Socket socket = null;
DataOutputStream dataOutputStream = null;
DataInputStream dataInputStream = null;

 try {           
      socket = new Socket("xxx.xx.xxx.xx", 2000);
      dataOutputStream = new DataOutputStream(socket.getOutputStream());
      dataInputStream = new DataInputStream(socket.getInputStream());
      dataOutputStream.writeBytes(commandline);
      //dataOutputStream.writeChars("Kacang Lupakan Kulit");

  } catch (UnknownHostException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      tv.setText(readStackTrace(e));
  } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();

      //tv.setText(readStackTrace(e));
  } finally{

  }

  if (dataOutputStream != null){
      try {
          dataOutputStream.close();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          //tv.setText(readStackTrace(e));
      }
  }

  if (dataInputStream != null){
      try {
          dataInputStream.close();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          //tv.setText(readStackTrace(e));
      }
  }


  if (socket != null){
      try {
          socket.close();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          // tv.setText(readStackTrace(e));
      }
  }

这是我声明选项卡的主要活动:

public class MainActivity extends TabActivity {
private TabHost aTab;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);        

    TabHost tabHost = getTabHost();

    TabSpec report = tabHost.newTabSpec("Report");
    report.setIndicator("Report", getResources().getDrawable(R.drawable.report_01));
    Intent reportIntent = new Intent(this, ReportActivity.class);
    report.setContent(reportIntent);

    TabSpec profile = tabHost.newTabSpec("Profile");
    profile.setIndicator("Profile", getResources().getDrawable(R.drawable.profile_01));
    Intent profileIntent = new Intent(this, ProfileActivity.class);
    profile.setContent(profileIntent);


    TabSpec about = tabHost.newTabSpec("About");
    about.setIndicator("About", getResources().getDrawable(R.drawable.about_01));
    Intent aboutIntent = new Intent(this, AboutActivity.class);
    about.setContent(aboutIntent);


    // Adding all TabSpec to TabHost
    tabHost.addTab(report); 
    tabHost.addTab(profile);
    tabHost.addTab(about); 
    }       
}

需要提交的数据在报告选项卡中。

**这与使用前使用的代码相同TabLayout,它确实传递了数据。

有人知道吗?请。

4

0 回答 0