Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java eclipse、android中html的问题_Java_Android_Html_Eclipse - Fatal编程技术网

Java eclipse、android中html的问题

Java eclipse、android中html的问题,java,android,html,eclipse,Java,Android,Html,Eclipse,除了html之外,这个程序中的所有内容都可以工作。当我尝试使用x或任何其他html代码时,代码根本不会格式化它。有什么想法吗?我通常让html工作。html不能与任何字符串数组一起使用。我知道我还没有为第二个字符串数组定义html。它只是不适用于我认为可以工作的第一个字符串数组 package wompa.pro; import java.util.Random; import android.app.Activity; import android.os.Bundle; import and

除了html之外,这个程序中的所有内容都可以工作。当我尝试使用x或任何其他html代码时,代码根本不会格式化它。有什么想法吗?我通常让html工作。html不能与任何字符串数组一起使用。我知道我还没有为第二个字符串数组定义html。它只是不适用于我认为可以工作的第一个字符串数组

package wompa.pro;

import java.util.Random;
import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.StyleSpan;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.TextView;
import android.widget.ViewFlipper;

public class Flashcard extends Activity implements OnClickListener{

    View.OnTouchListener gestureListener;
    ViewFlipper flipper;
    String facts[] = {
//Calculus

"Product Rule: d/dx(fg)=",
"Quotient Rule: d/dx(f/g)=",
"(d/dx)c=",
"(d/dx)cx=",
"(d/dx)x<sup>n</sup>=",
"(d/dx)e<sup>x</sup>=",
"(d/dx)ln(x)=",
"(d/dx)a<sup>x</sup>=",
"(d/dx)log<sub>a</sup>x=",
"(d/dx)sin(x)",
"(d/dx)cos(x)",
"(d/dx)tan(x)",
"(d/dx)csc(x)",
"(d/dx)sec(x)",
"(d/dx)cot(x)",
"d/dx(arcsin(x))",
"d/dx(arccos(x))",
"d/dx(arctan(x))",
"d/dx(arccsc(x))",
"d/dx(arcsec(x))",
"d/dx(arccot(x))",
};

    String answers[] = {
//Biology ch. 9

"f'g+fg'",
"(f'g-fg')/g<sup>2</sup>",
"0",
"c",
"nx<sup>n-1</sup>",
"e<sup>x</sup>",
"1/x",
"a<sup>x</sup>lna",
"(1/x)(1/lna)",
"cos(x)",
"-sin(x)",
"sec<sup>2</sup>x",
"-cscxcotx",
"secxtanx",
"-csc<sup>2</sup>",
"1/(1-x<sup>2</sup>)<sup>1/2</sup>",
"-1/(1-x<sup>2</sup>)<sup>1/2</sup>",
"1/(1+x<sup>2</sup>)",
"-1/(1+x<sup>2</sup>)",
"1/(|x|(x<sup>2</sup>-1)<sup>1/2</sup>)",
"-1/(|x|(x<sup>2</sup>-1)<sup>1/2</sup>)",
 };


private Animation inFromRightAnimation() {

Animation inFromRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT,  +1.0f, Animation.RELATIVE_TO_PARENT,  0.0f,
Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
);
inFromRight.setDuration(500);
inFromRight.setInterpolator(new AccelerateInterpolator());
return inFromRight;
}
private Animation outToLeftAnimation() {
Animation outtoLeft = new TranslateAnimation(
  Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  -1.0f,
  Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
);
outtoLeft.setDuration(500);
outtoLeft.setInterpolator(new AccelerateInterpolator());
return outtoLeft;
}

private Animation inFromLeftAnimation() {
Animation inFromLeft = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT,  -1.0f, Animation.RELATIVE_TO_PARENT,  0.0f,
Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
);
inFromLeft.setDuration(500);
inFromLeft.setInterpolator(new AccelerateInterpolator());
return inFromLeft;
}
private Animation outToRightAnimation() {
Animation outtoRight = new TranslateAnimation(
  Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  +1.0f,
  Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
);
outtoRight.setDuration(500);
outtoRight.setInterpolator(new AccelerateInterpolator());
return outtoRight;
}

TextView display, display1;
TextView counter;
Button begin;
Button next;
Button previous;
Button random;
Random myRandom;
TextView tvResults;

int index = facts.length;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);

 flipper = (ViewFlipper) findViewById(R.id.flipper);
 Button button1 = (Button) findViewById(R.id.Button01);
 Button button2 = (Button) findViewById(R.id.Button02);
 TextView t = (TextView)findViewById(R.id.tvResults);

 button1.setOnClickListener(new View.OnClickListener() {
     public void onClick(View view) {
         flipper.setInAnimation(inFromRightAnimation());
         flipper.setOutAnimation(outToLeftAnimation());
         flipper.showNext();               
     }
 });

 button2.setOnClickListener(new View.OnClickListener() {
     public void onClick(View view) {
         flipper.setInAnimation(inFromLeftAnimation());
         flipper.setOutAnimation(outToRightAnimation());
         flipper.showPrevious();      
     }
 });

 display = (TextView) findViewById(wompa.pro.R.id.tvResults);
 display1 = (TextView) findViewById(wompa.pro.R.id.tvAnswers);
    counter = (TextView) findViewById(wompa.pro.R.id.tvCounter);

    next = (Button) findViewById(wompa.pro.R.id.Next);
    previous = (Button) findViewById(wompa.pro.R.id.Previous);
    random = (Button) findViewById(wompa.pro.R.id.Random);

    next.setOnClickListener(this);
    previous.setOnClickListener(this);
    random.setOnClickListener(this);

    myRandom = new Random();
    index++;
    if (index > facts.length - 1) {
        index = 0;
    }
    showDisplay();}

private void showDisplay() {
    Spanned span = Html.fromHtml(facts[index]);
    SpannableStringBuilder builder = new SpannableStringBuilder(span);
    int start = builder.nextSpanTransition(0, builder.length(), StyleSpan.class);
    int stop = builder.nextSpanTransition(start, builder.length(), StyleSpan.class);
    builder.setSpan(span, start, stop, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    display.setText(facts[index]);
    display1.setText(answers[index]);
    counter.setText(String.valueOf(index + 1) + "/"
            + String.valueOf(facts.length));
}

public void onClick(View arg0) {
    // TODO Auto-generated method stub
    switch (arg0.getId()) {
    case wompa.pro.R.id.Next:
        index++;
        if (index > facts.length - 1) {
            index = 0;
        }
        showDisplay();

        break;

    case wompa.pro.R.id.Previous:
        index--;
        if (index < 0) {
            index = facts.length - 1;
        }
        showDisplay();
        break;

    case wompa.pro.R.id.Random:
        index = (myRandom.nextInt(facts.length) - 1);
        if (index < 0) {
            index = facts.length - 1;
        }
        showDisplay();
        break;

    }

}







}
package wompa.pro;
导入java.util.Random;
导入android.app.Activity;
导入android.os.Bundle;
导入android.text.Html;
导入android.text.SpannableStringBuilder;
导入android.text.span;
导入android.text.style.StyleSpan;
导入android.view.view;
导入android.view.view.OnClickListener;
导入android.view.animation.AccelerateInterpolator;
导入android.view.animation.animation;
导入android.view.animation.TranslateAnimation;
导入android.widget.Button;
导入android.widget.TextView;
导入android.widget.ViewFlipper;
公共类Flashcard扩展活动实现OnClickListener{
View.OnTouchListener手势Listener;
视图翻转器翻转器;
字符串事实[]={
//微积分
“产品规则:d/dx(fg)=”,
“商规则:d/dx(f/g)=”,
“(d/dx)c=”,
“(d/dx)cx=”,
“(d/dx)xn=”,
“(d/dx)ex=”,
“(d/dx)ln(x)=”,
“(d/dx)ax=”,
“(d/dx)logax=”,
“(d/dx)sin(x)”,
“(d/dx)cos(x)”,
“(d/dx)tan(x)”,
“(d/dx)csc(x)”,
“(d/dx)第(x)节”,
“(d/dx)cot(x)”,
“d/dx(Arcin(x))”,
“d/dx(arccos(x))”,
“d/dx(arctan(x))”,
“d/dx(arccsc(x))”,
“d/dx(arcsec(x))”,
“d/dx(arccot(x))”,
};
字符串答案[]={
//生物学第9章
“f'g+fg”,
“(f'g-fg')/g2”,
"0",
“c”,
“nxn-1”,
“前”,
“1/x”,
“axlna”,
“(1/x)(1/lna)”,
“cos(x)”,
“-sin(x)”,
“sec2x”,
“-cscxcotx”,
“secxtanx”,
“-csc2”,
“1/(1-x2)1/2”,
“-1/(1-x2)1/2”,
“1/(1+x2)”,
“-1/(1+x2)”,
“1/(|x |(x2-1)1/2)”,
“-1/(|x |(x2-1)1/2)”,
};
私有动画INFORMORightAnimation(){
动画信息右侧=新的TranslateAnimation(
Animation.RELATIVE_TO_PARENT,+1.0f,Animation.RELATIVE_TO_PARENT,0.0f,
Animation.RELATIVE\u TO\u PARENT,0.0f,Animation.RELATIVE\u TO\u PARENT,0.0f
);
设置持续时间(500);
setInterpolator(新的AccelerateInterpolator());
返回版权;
}
私有动画outToLeftAnimation(){
动画outtoLeft=新的TranslateAnimation(
Animation.RELATIVE\u到\u父级,0.0f,Animation.RELATIVE\u到\u父级,-1.0f,
Animation.RELATIVE\u TO\u PARENT,0.0f,Animation.RELATIVE\u TO\u PARENT,0.0f
);
outtoLeft.设置持续时间(500);
outtoLeft.setInterpolator(新的AccelerateInterpolator());
返回outtoLeft;
}
私有动画INFOROMLEFTANIMATION(){
动画信息左=新的TranslateAnimation(
Animation.RELATIVE_TO_PARENT,-1.0f,Animation.RELATIVE_TO_PARENT,0.0f,
Animation.RELATIVE\u TO\u PARENT,0.0f,Animation.RELATIVE\u TO\u PARENT,0.0f
);
设置持续时间(500);
setInterpolator(新的AccelerateInterpolator());
返回左前;
}
私有动画outToRightAnimation(){
动画输出光=新的TranslateAnimation(
Animation.RELATIVE_TO_PARENT,0.0f,Animation.RELATIVE_TO_PARENT,+1.0f,
Animation.RELATIVE\u TO\u PARENT,0.0f,Animation.RELATIVE\u TO\u PARENT,0.0f
);
outtoRight.setDuration(500);
setInterpolator(新的AccelerateInterpolator());
返回右侧;
}
文本视图显示,显示1;
文本视图计数器;
按钮开始;
按钮下一步;
按钮前;
按钮随机;
随机myRandom;
文本查看结果;
int index=facts.length;
/**在首次创建活动时调用*/
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
flipper=(ViewFlipper)findViewById(R.id.flipper);
按钮button1=(按钮)findViewById(R.id.Button01);
Button button2=(按钮)findViewById(R.id.Button02);
TextView t=(TextView)findViewById(R.id.tvResults);
button1.setOnClickListener(新视图.OnClickListener(){
公共void onClick(视图){
flipper.setInAnimation(INFOROMRightAnimation());
setOutAnimation(outToLeftAnimation());
flipper.showNext();
}
});
button2.setOnClickListener(新视图.OnClickListener(){
公共void onClick(视图){
flipper.setInAnimation(INFOROMLEFTANIMATION());
setOutAnimation(outToRightAnimation());
flipper.showPrevious();
}
});
display=(TextView)findViewById(wompa.pro.R.id.tvResults);
display1=(TextView)findViewById(wompa.pro.R.id.tvAnswers);
计数器=(TextView)findViewById(wompa.pro.R.id.tvCounter);
next=(按钮)findviewbyd(wompa.pro.R.id.next);
previous=(按钮)findviewbyd(wompa.pro.R.id.previous);
随机=(按钮)findViewById(wompa.pro.R.id.random);
next.setOnClickListener(this);
previous.setOnClickListener(此);
random.setOnClickListener(这个);
myRandom=新随机数();
索引++;
如果(索引>事实长度-1){
指数=0;
}
showDisplay();}
私有void showDisplay(){
span=Html.fromHtml(事实[索引]);
SpannableStringBuilder=新的SpannableStringBuilder(span);
int start=builder.nextspanttransition(0,builder.length(),StyleSpan.class);
int stop=builder.nextspanttransition(start,builder.length(),StyleSpan.class);
建造商设置范围(跨度、开始、停止、跨距、包括/不包括);
display.setText(事实[索引]);
display1.setText(答案[索引]);
counter.setText(String.valueOf(index+1)+“/”
+String.valueOf(facts.length));
}
公共void onClick(视图arg0){
//TODO自动生成的方法存根
开关(arg0.getId()){
案例wompa.pro.R.id.Next:
索引++;
如果(索引>事实长度-1){
指数=0;
}
showDisplay();
打破
案例wompa.pro.R.id.先前:
索引--;
如果(指数<0){
索引=facts.length-1;
}
showDisplay();
打破
案例wompa.pro.R.id.Random:
索引=(myRandom.nextInt(facts.length)-1);
如果(指数<0){
display.setText(Html.fromHtml(string));