在启动activity中找不到合适的方法是显示错误的错误是:
错误:(123,17)错误:找不到适合startActivities(Intent)方法上下文的方法。startActivities(Intent[])不适用(参数不匹配;Intent无法转换为Intent[])方法上下文。startActivities(Intent[])不适用(参数不匹配;Intent无法转换为Intent[])方法活动。startActivities(Intent[])不适用(参数不匹配;Intent无法转换为Intent[])包com.SmartCodeOne.NewApp1;
public class MainActivity extends ListActivity{
public static final String STRING_VAR = "com.smartcodeone.newapp1.HELLO_WORLD";
public static final String STRING_RATE = "com.smartcodeone.newapp1.RAIING";
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
private GoogleApiClient client;
public ListView listView_allContacts;
//ArrayAdapter adapter=new ArrayAdapter<String>(this,R.layout.,StringArray);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView_allContacts=getListView();
//(ListView) findViewId(R.id.listView_allContacts);
//listView_allContacts.setAdapter(adapter);
Button btnMsg = (Button) findViewById(R.id.btnMsg);
Button btnint = (Button) findViewById(R.id.btnshare);
// Button btnWidge t = (Button) findViewById(R.id.btnwidget);
// TextView etName1 = (TextView) findViewId(R.id.etName);
// EditText etName = (EditText) findViewId(R.id.tvName);
btnMsg.setOnClickListener(new View.OnClickListener() {
//when user click's this function will be called
public void onClick(View v) {
Intent intentvar = new Intent(getApplicationContext(), Main2Activity.class);
intentvar.putExtra(STRING_VAR, "Hello World"); //this is used to pass data to next intent
intentvar.putExtra(STRING_RATE, 3);
startActivity(intentvar);
}
});
btnint.setOnClickListener(new View.OnClickListener() {
//when user want to share something
public void onClick(View v) {
Intent intentShare = new Intent(Intent.ACTION_SEND);
intentShare.setType("text/palin");
intentShare.putExtra(Intent.EXTRA_TEXT, "This is invitation to all my friend to see this app");
//ensure we have an appliction that can handle this type of data
if (intentShare.resolveActivity(getPackageManager()) != null) {
startActivity(intentShare);
}
}
});
/*btnWidget.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intentwid = new Intent(getApplicationContext(), NewAppWidget.class);
startActivity(intentwid);
}
});
*/
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
private int findViewId(int btnMsg) {
return 0;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
switch (item.getItemId()){
case R.id.menu_new_contact:
// startActivities(new Intent(MainActivity.this, ContactDetailsActivity.class));
break;
}
return super.onOptionsItemSelected(item);
}
/* @Override
public FragmentManager getSupportFragmentManager() {
return null;
}
*/
@Override
public void onStart() {
super.onStart();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client.connect();
Action viewAction = Action.newAction(
Action.TYPE_VIEW, // TODO: choose an action type.
"Main Page", // TODO: Define a title for the content shown.
// TODO: If you have web page content that matches this app activity's content,
// make sure this auto-generated web page URL is correct.
// Otherwise, set the URL to null.
Uri.parse("http://host/path"),
// TODO: Make sure this auto-generated app URL is correct.
Uri.parse("android-app://com.smartcodeone.newapp1/http/host/path")
);
AppIndex.AppIndexApi.start(client, viewAction);
}
@Override
public void onStop() {
super.onStop();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
Action viewAction = Action.newAction(
Action.TYPE_VIEW, // TODO: choose an action type.
"Main Page", // TODO: Define a title for the content shown.
// TODO: If you have web page content that matches this app activity's content,
// make sure this auto-generated web page URL is correct.
// Otherwise, set the URL to null.
Uri.parse("http://host/path"),
// TODO: Make sure this auto-generated app URL is correct.
Uri.parse("android-app://com.smartcodeone.newapp1/http/host/path")
);
AppIndex.AppIndexApi.end(client, viewAction);
client.disconnect();
}
/* protected void onResume(){
Dbhelper db =new Dbhelper(this);
ArrayList<String> names=new ArrayList<String>();
for(int i=0;i<db.getAllContact().size();i++)
names.add(db.getAllContact().get(i).getName());
ArrayAdapter adapter =new ArrayAdapter(this,android.R.layout.simple_list_item_1,names);
listView_allContacts.setAdapter(adapter);
}*/
}
替换(在OnOptionSitemSelected
方法中):
startActivities(new Intent(MainActivity.this, ContactDetailsActivity.class));
与:
startActivity(new Intent(MainActivity.this, ContactDetailsActivity.class));
我想收集一些数据并将其存储到数据库(在Java中,使用MySQL)。其中一个数据是日期(创建/插入此条目时)。 我已经试过了 将日期转换为SQL友好的格式,但我仍然得到错误 找不到适合getDate(Date)的方法 方法结果集。getDate(int)不适用 (参数不匹配;日期无法转换为int) 方法ResultSet.get日期(字符串)不适用 (参数不匹配;日期无法转换为字符串) 错误发生在
我试图在Flink的数据流上应用每窗口功能。以下是我的代码 下面是我的实现MyProcessWindow函数 然而,当我试图通过maven编译上述代码时,我得到了以下错误 知道我做错了什么吗?仅供参考,我正在使用ApacheFlink 1.5.1版,并在Mac上使用maven3编译Java代码。
算法问题:给定一个非负整数列表,将它们排列成最大的数。 例如,给定[3,30,34,5,9],形成的最大数是9534330。 注意:结果可能很大,因此需要返回一个字符串,而不是整数。 而且我还在想办法避免使用额外的空间。
我需要创建一个以id和值作为资源的ArrayList,这样我将来就可以知道给定图标在哪个id下。不幸的是,我的解决方案遇到了一个问题,如何解决? 我给出了一个错误: 错误:找不到添加(int,int)航路点图标的合适方法。添加(0,R.drawable.ic_point_默认值)
我试图用java创建一个分数计算器,我使用drop box int Joptionpane来显示算术运算,但是每当我编译代码时,总是会出现错误。 这是我得到的全部错误。 .java:47:错误:找不到适合showInputDialog(,String,int,,String[],String)的方法String input=(String)JOptionPane。showInputDialog(n
我有一个问题关于start活动(意图)和onStop。Android API建议在onStop中保存数据,这就是我在这里所做的: 但是,我想在保存下一个活动后启动它-因此我需要使用intent和startActivity(intent)。 我的问题是,带两个标志的startActivity(intent)是在完成应用程序时调用onStop()方法,还是需要调用finish()?是否允许我在开始新活