我的应用程序在左侧使用ListFragment,用户可以使用它来选择右侧使用的片段.
在排序中,似乎不可能多次显示MapView.第一个问题是它只允许每个Activity有一个MapView实例.
# Exception 1:
You are only allowed to have a single MapView in a MapActivity
Run Code Online (Sandbox Code Playgroud)
因此,我将我的MapView和容器保存在Activity类中:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FragmentManager.enableDebugLogging(true);
setContentView(R.layout.main);
mapViewContainer = LayoutInflater.from(this).inflate(R.layout.maplayout, null);
mapView = (MapView) mapViewContainer.findViewById(R.id.map_view);
}
Run Code Online (Sandbox Code Playgroud)
但是,这给了我下一个问题:
# Exception 2:
The specified child already has a parent.
You must call removeView() on the child’s parent first.
Run Code Online (Sandbox Code Playgroud)
我试图删除视图,使用此代码:
((ViewGroup)mapViewContainer).removeView(mapView);
((ViewGroup)mapView.getParent()).removeView(mapView);
Run Code Online (Sandbox Code Playgroud)
得到了NullPointerExeption.
我会很感激任何好的想法,或者如果你能成功的话,你会分享吗?
谢谢 :)
美好的一天,我有一个简单的网页,里面有一个电子邮件表格.我正在尝试从中收集数据并填充数据库而不刷新模板.到目前为止,这是我的代码:
形成:
from flask_wtf import Form
class EmailForm(Form):
email = StringField('Email Address', [
DataRequired(message='Required field'),
Email(message='Please provide a valid email address')
])
submit = SubmitField('send')
Run Code Online (Sandbox Code Playgroud)
路线:
@app.route('/', methods=('GET', 'POST'))
def index():
form = EmailForm(request.form)
if request.method == 'POST' and form.validate_on_submit():
try:
email = Email(form.data['email'])
db.session.add(email)
db.session.commit()
except IntegrityError as e:
app.logger.info(e)
return redirect(url_for('index'))
return render_template('index.html', form=form)
Run Code Online (Sandbox Code Playgroud)
阿贾克斯:
$(function() {
$('#email_submit').bind('click', function() {
$.getJSON('/', {
email: $('input[name="email"]').val()
});
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
模板:
<form name="collectEmail" id="collectForm" method="post" action="{{ url_for('index') }}">
{{ …Run Code Online (Sandbox Code Playgroud) BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Run Code Online (Sandbox Code Playgroud)
System.in(Standard input stream)- 以字节为单位从键盘获取输入
InputStreamReader: 将字节转换为Unicode字符/将标准输入转换为读取器对象以与BufferedReader一起使用
Finally BufferedReader:用于从字符输入流中读取(输入流读取器)
String c = br.ReadLine(); - 一种用于从输入流中读取字符并将其一次性放入字符串中的方法.
一切都在正确吗?如果有什么不对请更正!