我如何将此代码放入TabView?

时间:2013-12-13 01:42:23

标签: android

我在TabView类中有这个代码:

package jungle.timer;


import com.example.jungletimer.R;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;



public class JungleTimers extends Fragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.jungle_timers, container, false);

    return rootView;
}
}

但是我想将这段代码(↓↓↓)放入其他(↑↑↑),我明白了,因为我不知道怎么做将两个代码放在一起。 PD:我是新手D:

https://github.com/Hersix/Codigos/blob/master/Code%20app

1 个答案:

答案 0 :(得分:1)

package jungle.timer;


import com.example.jungletimer.R;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;



public class JungleTimers extends Fragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.jungle_timers, container, false);

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

                final TextView Texto = (TextView)rootView. findViewById(R.id.textView1);


                ImageView Start = (ImageView)rootView.findViewById(R.id.imageView1);
                Start.setOnClickListener(new OnClickListener(){

                        @Override
                        public void onClick(View v) {
                                new CountDownTimer(30000, 1000) {

                                     @Override
                                        public void onTick(long millisUntilFinished) {
                                         Texto.setText("" + millisUntilFinished / 1000);
                                     }

                                     @Override
                                        public void onFinish() {
                                         Texto.setText("");
                                     }
                                  }.start();
                        }});

    return rootView;
}
}

这样的东西?