我见过一些将文件导入.db的资源,但它不是动态的。当我Matrix A;
vector<double> a1, a2, a3, a4;
a1.push_back(0);
a1.push_back(2);
a1.push_back(0);
a1.push_back(-2);
a1.push_back(2.5);
a2.push_back(2);
a2.push_back(0);
a2.push_back(1);
a2.push_back(0);
a2.push_back(1.6);
a3.push_back(-2);
a3.push_back(0);
a3.push_back(1);
a3.push_back(0);
a3.push_back(0);
a4.push_back(2.5);
a4.push_back(1.6);
a4.push_back(0);
a4.push_back(0);
a4.push_back(0);
A.push_back(a1);
A.push_back(a2);
A.push_back(a3);
A.push_back(a4);
喜欢.csv或.xls然后点击某个按钮You may use the alternate solution to achieve the same
Below is the complete code that will help you to put scrolling text hope it will help you.
1.Create a class which extends the Text View e.g
public class ScrollText extends TextView {
// scrolling feature
private Scroller mSlr;
// milliseconds for a round of scrolling
private int mRndDuration = 5000;
// the X offset when paused
private int mXPaused = 0;
// whether it's being paused
private boolean mPaused = true;
//constructor
public ScrollText(Context context) {
this(context, null);
// customize the TextView
setSingleLine();
setEllipsize(null);
setVisibility(INVISIBLE);
}
//constructor
public ScrollText(Context context, AttributeSet attrs) {
this(context, attrs, android.R.attr.textViewStyle);
// customize the TextView
setSingleLine();
setEllipsize(null);
setVisibility(INVISIBLE);
}
//constructor
public ScrollText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// customize the TextView
setSingleLine();
setEllipsize(null);
setVisibility(INVISIBLE);
}
/**
* begin to scroll the text from the original position
*/
public void startScroll() {
// begin from the very right side
mXPaused = -1 * getWidth();
// assume it's paused
mPaused = true;
resumeScroll();
}
/**
* resume the scroll from the pausing point
*/
@SuppressLint("UseValueOf")
public void resumeScroll() {
if (!mPaused)
return;
// Do not know why it would not scroll sometimes
// if setHorizontallyScrolling is called in constructor.
setHorizontallyScrolling(true);
// use LinearInterpolator for steady scrolling
mSlr = new Scroller(this.getContext(), new LinearInterpolator());
setScroller(mSlr);
int scrollingLen = calculateScrollingLen();
int distance = scrollingLen - (getWidth() + mXPaused);
int duration = (new Double(mRndDuration * distance * 1.500000
/ scrollingLen)).intValue();
setVisibility(VISIBLE);
mSlr.startScroll(mXPaused, 0, distance, 0, duration);
invalidate();
mPaused = false;
}
/**
* calculate the scrolling length of the text in pixel
*
* @return the scrolling length in pixels
*/
private int calculateScrollingLen() {
TextPaint tp = getPaint();
Rect rect = new Rect();
String strTxt = getText().toString();
tp.getTextBounds(strTxt, 0, strTxt.length(), rect);
int scrollingLen = rect.width() + getWidth();
rect = null;
return scrollingLen;
}
/**
* pause scrolling the text
*/
public void pauseScroll() {
if (null == mSlr)
return;
if (mPaused)
return;
mPaused = true;
// abortAnimation sets the current X to be the final X,
// and sets isFinished to be true
// so current position shall be saved
mXPaused = mSlr.getCurrX();
mSlr.abortAnimation();
}
@Override
/*
* override the computeScroll to restart scrolling when finished so as that
* the text is scrolled forever
*/
public void computeScroll() {
super.computeScroll();
if (null == mSlr)
return;
if (mSlr.isFinished() && (!mPaused)) {
this.startScroll();
}
}
public int getRndDuration() {
return mRndDuration;
}
public void setRndDuration(int duration) {
this.mRndDuration = duration;
}
public boolean isPaused() {
return mPaused;
}
}
2. in the onCreate() of main activity paste the code shown below
ScrollText scrolltext = (ScrollText) findViewById(R.id.footer_tv_scroll);
String textToscroll = "YOUR TEXT"
scrolltext.setText(s);
scrolltext.setTextColor(Color.BLACK);
scrolltext.startScroll();
3. inside your xml place the code shown below
<<YOUR PACKAGE NAME>.ScrollText
android:id="@+id/footer_tv_scroll"
android:layout_width="650dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/footer_iv_logo"
android:textSize="35sp"
android:textStyle="bold" />
hope this works
Cheers!
时,我如何制作我的应用程序?choose any file
?
答案 0 :(得分:0)
sqlite没有导入文件的api。所以你必须从文件中读取数据并编写SQL。 csv文件数据格式非常简单,但xls文件很复杂。