如何解决无法在 android studio v4.2 的主要活动中定义公共访问修饰符
我无法在 android studiov4.2 的主类中声明公共类下载
public class MainActivity extends AppCompatActivity {
//Intialistion of variables:
ListView listView;
ArrayList<String> arrayList = new ArrayList<String>();
ArrayAdapter arrayAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//declaration of variables :
listView = findViewById(R.id.ListView);
arrayAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1);
listView.setAdapter(arrayAdapter);
public class Download extends AsyncTask<String,Void,String>{
@Override
protected String doInBackground(String... strings) {
return null;
}
}
}
}
[Screenshot of error is attached see it for refrence][1]
[1]: https://i.stack.imgur.com/DbqDY.png
错误 - 此处不允许使用修饰符“public”
解决方法
大声笑,错误解决了 - 我在 OnCreate 方法 中创建了 public Class DownLoad ,现实是你不能在一个已经在类称为“主要”。又名 - 方法可以在类中创建,反之亦然。抱歉犯了一个愚蠢的错误。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。