我有一个应用程序,登录后它会在欢迎屏幕上引发你.我放了一个Toast来看看onResume何时触发,但它也会在onCreate之后触发
protected void onResume(){
super.onResume();
Database openHelper = new Database(this);//create new Database to take advantage of the SQLiteOpenHelper class
myDB2 = openHelper.getReadableDatabase(); // or getWritableDatabase();
myDB2=SQLiteDatabase.openDatabase("data/data/com.example.login2/databases/aeglea", null, SQLiteDatabase.OPEN_READONLY);//set myDB to aeglea
cur = fetchOption("SELECT * FROM user_login");//use above to execute SQL query
msg.setText("Username: "+cur.getString(cur.getColumnIndex("username"))
+"\nFull name: "+cur.getString(cur.getColumnIndex("name"))+" "+cur.getString(cur.getColumnIndex("last"))
+"\ne-mail: "+cur.getString(cur.getColumnIndex("email"))
+"\nAeglea id:"+cur.getString(cur.getColumnIndex("uid")));
Toast.makeText(getApplicationContext(), "RESUMED", Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)
它来自:
//create new intent
Intent log = new Intent(getApplicationContext(), Welcome.class);
// Close all views before launching logged
log.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(log);
// Close Login Screen
finish(); …Run Code Online (Sandbox Code Playgroud) 我正在开始我的论文,这是一个Android的应用程序.这个应用程序基于我创建的Web平台.
我需要建议的部分是:这是将数据从MySQL服务器提取到应用程序中的最有效方法.请给我一些建议和你对此事的经验.
(我已经阅读了关于在json中对查询进行编码的信息,但看起来似乎有很多不必要的工作)
我已经创建了一个自定义栏,其中包含属性的按钮
android:background="@android:color/transparent"
Run Code Online (Sandbox Code Playgroud)
我的问题是,当我点击按钮时,点击效果不会触发(在这种情况下,按钮应该变成蓝色并以原始颜色淡化 - 透明 - 这里 - ).
如何启用它或仅模拟效果?有任何想法吗?
我需要从列表列表创建一棵二叉树。我的问题是一些节点重叠(从某种意义上说,一个节点的左子节点是另一个节点的右侧),我想将它们分开。
我复制了重叠的节点并创建了一个列表,但我遗漏了一些东西。我用来做到这一点的代码:
self.root = root = BNodeItem(values[0][0], 0)
q = list()
q.append(root)
# make single tree list
tree_list = list()
tree_list.append(values[0][0])
for i in xrange(1, len(values[0])):
ll = [i for i in numpy.array(values)[:, i] if i is not None]
# duplicate the values
p = []
for item in ll[1:-1]:
p.append(item)
p.append(item)
new_ll = list()
new_ll.append(ll[0])
new_ll.extend(p)
new_ll.append(ll[-1])
tree_list.extend(new_ll)
# fix tree
for ind in xrange(len(tree_list)/2 - 1):
eval_node = q.pop(0)
eval_node.left = BNodeItem(tree_list[2*ind + 1], 0)
eval_node.right = BNodeItem(tree_list[2*ind …Run Code Online (Sandbox Code Playgroud) 我想知道在内部类中调用外部Class方法然后在外部类中使用内部Class方法被认为是不好的做法.
在这种情况下:在BidParser中,我调用属于外部类的方法updateMaps().另外,我在BidParser中调用了第二个内部类InputSanityChecker的方法.
这是不好的做法和反模式吗?我在这里创建一个上帝对象吗?(但是在其他外部类中可以使用更多函数)
编辑:我有两个变量Var1,Var2(让我们说)属于外部但是updateX和checkX方法需要.
public class Outer{
public static void main( String[] args ){
if(args.length == 1){
File file = new File(args[0]);
BidParser.parseBids(file);//<--- Question refers here
}else{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BidParser.parseBids(br); //<--- and here
}
}
private static void updateMaps(String[] elements){
//.....blah blah
}
static class BidParser{
public static void parseBids(File file){
//.....blah blah
InputSanityChecker.checkInput(elems);//<---second inner class method
InputSanityChecker.checkMaps(elems); //<---second inner class method
updateMaps(elems); //<-----outer class method
} …Run Code Online (Sandbox Code Playgroud) 我有一个活动,它调用onItemClick并启动另一个活动.这个活动有一个静态布局(用于测试目的),但我看到的只是黑色(我甚至将文本颜色设置为白色来检查它).
我的倾听者
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
//create new intent
Intent item = new Intent(getApplicationContext(), Item.class);
// Close all views before launching logged
//item.putExtra("name", ((TextView)arg1).getText());
//item.putExtra("uid", user_id);
item.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(item);
// Close Login Screen
onPause();
}
});
Run Code Online (Sandbox Code Playgroud)
我的活动在这里(没有太多的事情只是启动布局)
public class Item extends Activity{
protected SQLiteDatabase myDB=null;
protected String name;
protected int uid;
TextView yeart,year,itemname,comment,commentt,value,valuet,curr,currt;
protected void onStart(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.herp);
/*name=getIntent().getStringExtra("name");
uid=Integer.parseInt(getIntent().getStringExtra("uid"));
itemname=(TextView) findViewById(R.id.itemName);//itemname.setText(name);
year=(TextView) findViewById(R.id.itemYear);
yeart=(TextView) findViewById(R.id.year);
comment=(TextView) findViewById(R.id.itemComments);
commentt=(TextView) findViewById(R.id.comments);
curr=(TextView) …Run Code Online (Sandbox Code Playgroud)