以下是我要实现的内容:当人们点击工具栏右上角的菜单时,屏幕底部会显示一个选项菜单.见下图:
我不确定应该在底部调用该项目的方法.有人可以给我一些关于如何实现这一点的提示吗?
我使用下面的代码成功实现了右上方菜单栏中的图标.但我不知道如何在屏幕底部显示宽度match_parent和高度的选项wrap_content
点击右上角
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.edit_profile_image_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch (id) {
case R.id.more:
//How to show the 2 option in the bottom of screen here
return true;
}
return super.onOptionsItemSelected(item);
}
Run Code Online (Sandbox Code Playgroud)
更新
实现Nikesh的代码后,弹出窗口显示如下:
我使用Retrofit 2将视频文件(从相机捕获)发送到我的PHP服务器,视频成功上传到服务器中的文件夹(我使用FileZilla检查,视频存在于文件夹中),我将视频分配给URL,我去同一个网址(使用浏览器)它无法播放视频.
它只是在Url中显示(例如:mydomain.cc/video/VID_2014.mp4)
所以我用随机视频测试,通过邮递员发送,该视频的URL能够播放.
像这样:
Android中我在onActivityResult捕获视频后进入的视频文件路径如下所示
/storage/emulated/0/DCIM/ABC/VID_20171008_183129.mp4
这是我发送视频文件的代码
private void uploadVideoToServer(String pathToVideoFile){
File videoFile = new File(pathToVideoFile);
RequestBody videoBody = RequestBody.create(MediaType.parse("video/*"), videoFile);
MultipartBody.Part vFile = MultipartBody.Part.createFormData("video", videoFile.getName(), videoBody);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(SERVER_PATH)
.addConverterFactory(GsonConverterFactory.create())
.build();
VideoInterface vInterface = retrofit.create(VideoInterface.class);
Call<ResultObject> serverCom = vInterface.uploadVideoToServer(vFile);
serverCom.enqueue(new Callback<ResultObject>() {
@Override
public void onResponse(Call<ResultObject> call, Response<ResultObject> response) {
ResultObject result = response.body();
if(!TextUtils.isEmpty(result.getSuccess())){
Toast.makeText(MainActivity.this, "Result " + result.getSuccess(), Toast.LENGTH_LONG).show();
Log.d(TAG, "Result " + result.getSuccess());
}
}
@Override
public void onFailure(Call<ResultObject> call, …Run Code Online (Sandbox Code Playgroud) android video-recording mediarecorder android-mediarecorder retrofit2
我有2个片段通话CreateRoomFragment和DisplayPhotoFragment,导航图是这个样子的:
<navigation>
<fragment
android:id="@+id/createRoomFragment"
android:name="package.room.CreateRoomFragment"
android:label="Create a room"
tools:layout="@layout/fragment_create_room">
<action
android:id="@+id/action_createRoomFragment_to_roomFragment"
app:destination="@id/roomFragment" />
<action
android:id="@+id/action_createRoomFragment_to_displayPhotoFragment"
app:destination="@id/displayPhotoFragment" />
</fragment>
<fragment
android:id="@+id/displayPhotoFragment"
android:name="package.fragment.DisplayPhotoFragment"
android:label="fragment_display_photo"
tools:layout="@layout/fragment_display_photo" >
<argument android:name="bitmap"
app:argType="android.graphics.Bitmap"/>
</fragment>
Run Code Online (Sandbox Code Playgroud)
所以当我想从 to 移动CreateRoomFragment时DisplayPhotoFragment,我使用如下 do:
NavDirections action = CreateRoomFragmentDirections.actionCreateRoomFragmentToDisplayPhotoFragment(selectedPhoto);
Navigation.findNavController(view).navigate(action);
Run Code Online (Sandbox Code Playgroud)
这样做,我可以导航到DisplayPhotoFragment.
但是当我按下back设备的按钮以及Back arrow工具栏中的 时,它无法返回到CreateRoomFragment。
我试过这个,但仍然无法回到上一个片段:
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(),
new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
navController.navigateUp(); //I tried this
navController.popBackStack(R.id.createRoomFragment,false); //and also this
}
});
Run Code Online (Sandbox Code Playgroud)
现在主要问题:
使用上面的代码,屏幕没有回到之前的Fragment( …
android android-fragments android-navigation android-architecture-navigation android-navigation-graph
我的应用程序记录了一个音频剪辑,并在录制完成后使用Retrofit2将剪辑发送到服务器。该文件已在服务器中接收到,但文件已损坏,我的意思是无法播放。我使用以下URL(示例url:)mydomain.co/audio/myaudio.mp4播放音频剪辑,我尝试使用另一个音频文件播放该音频剪辑,该postman音频文件可以成功播放。此外,即使通过android下载的android捕获的音频剪辑Filezilla也具有相同的损坏文件。
这是我录制音频的方式:
private void startRecordingAudio() {
Log.d("audiorecording","recording sound");
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.setAudioEncodingBitRate(16);
recorder.setAudioSamplingRate(44100);
MediaFileHelper fileHelper = new MediaFileHelper();
audioOutputFile = fileHelper.getOutputAudioFile();
recorder.setOutputFile(audioOutputFile.getAbsolutePath());
try {
recorder.prepare();
recorder.start();
} catch (IllegalStateException | IOException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
这是音频文件的文件路径:
/storage/emulated/0/DCIM/myapp/AUDIO_20171023143717.mp4
为了解决这个问题,我尝试使用不同的编解码器和不同的输出格式,如下
recorder.setOutputFormat(MediaRecorder.OutputFormat.THERE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THERE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_WB);
Run Code Online (Sandbox Code Playgroud)
我也试图改变文件扩展名.mp3,.mp4并.3gpp为好,但他们都不工作在服务器端。为了清楚起见,我使用以下代码附加了用于将音频文件发送到服务器的代码Retrofit2:
private void sendAudioToServer( final String audioFilePath,final String api_key){
Log.d("AUDIO FILE PATH",audioFilePath);
File audioFile = new File(audioFilePath);
RequestBody audioBody …Run Code Online (Sandbox Code Playgroud) 我使用MediaRecorder录制视频。使用后置摄像头时,它可以正常工作,但是使用前置摄像头时,捕获的视频被翻转/反转。这意味着右侧的项目将出现在左侧。摄像头预览可以正常工作,只是最终捕获的视频翻转了。
这是相机预览的样子
但是最终的视频看起来像这样(所有项目都出现在左侧,出现在右侧)
到目前为止我尝试过的是:
我尝试使用“ matrix准备记录器”,但似乎并没有改变。
private boolean prepareRecorder(int cameraId){
//# Create a new instance of MediaRecorder
mRecorder = new MediaRecorder();
setCameraDisplayOrientation(this,cameraId,mCamera);
int angle = getVideoOrientationAngle(this,cameraId);
mRecorder.setOrientationHint(angle);
if(cameraId == Camera.CameraInfo.CAMERA_FACING_FRONT){
Matrix matrix = new Matrix();
matrix.preScale(1.0f,-1.0f);
}
//all other code to prepare recorder here
}
Run Code Online (Sandbox Code Playgroud)
我已经在下面阅读了所有此问题,但似乎所有这些SurfaceView都未能解决我的问题。有关信息,我使用的是相机预览,所以这里的问题无济于事。
所以我的问题是:
1)如何通过前置摄像头捕获视频,而不是反向视频(与摄像头预览完全相同)?
2)如何在SurfaceView不使用相机预览的情况下实现此目的TextureView?(因为我上面提到的所有问题,告诉有关使用TextureView)
欢迎所有可能的解决方案..Tq
编辑
我制作了2个简短的视频片段以阐明问题,请下载并查看
我将 React leaflet 与自定义 CRS、Leaflet CRS 文档一起使用
我想做的是:
ImageOverlayImageOverlay这是我的尝试:
地图容器
<MapContainer
center={[250, 500]}
zoom={0}
style={{ height: '100vh', width: '100%' }}
crs={L.CRS.Simple as CRS}
maxZoom={2}
zoomControl={false}
doubleClickZoom={false}
scrollWheelZoom={false}
dragging={false}
>
<MapClick />
{/**This is where I display the marker */}
{routePoints.map((point, index) => (
<Marker
key={index}
position={point}
icon={L.icon({
iconUrl: `${playerMarkerAssest}`,
iconSize: [35, 35],
})}
/>
))}
{/**This is the image url */}
<ImageOverlay url={mapAssest} bounds={imageBounds} />
</MapContainer>
Run Code Online (Sandbox Code Playgroud)
使用地图事件
useMapEvents({
click: (e) => {
setRoutePoints([...routePoints, e.latlng]); …Run Code Online (Sandbox Code Playgroud) I have a stack view that look like the figure below:
So I change the height of the image programmatically to make it fit the image that download from my server,if dont have image,the height constraints of image will set to be zero.
Here is my code to doing so:
let imageUrl = URL(string :imageString)
if let data = try? Data(contentsOf: imageUrl!)
{
guard let actualImage: UIImage = UIImage(data: data) else{
print("No image!")
ImageView.image = nil
defaultImageHeightContrainst = ImageHeightContrainst.constant
ImageHeightContrainst.constant …Run Code Online (Sandbox Code Playgroud) 我是 Python 初学者,我现在使用 Flask 和 SQLAlchemy 创建简单的数据库,如下所示:
..import all the stuff here
Base = declarative_base()
class Restaurant(Base):
__tablename__ = 'restaurant'
id = Column(Integer, primary_key=True)
name = Column(String(250), nullable=False)
class MenuItem(Base):
__tablename__ = 'menu_item'
name = Column(String(250), nullable=False)
id = Column(Integer, primary_key=True)
description = Column(String(250))
price = Column(String(8))
course = Column(String(250))
restaurant_id = Column(Integer, ForeignKey("restaurant.id"))
restaurant = relationship(Restaurant)
engine = create_engine('sqlite:///restaurant.db')
Base.metadata.create_all(engine)
Run Code Online (Sandbox Code Playgroud)
我有 PHP 和 MySQL 背景,所以我的问题是:
我正在使用 PyCharm IDE。我听说 PyCharm 有一个内置的功能来检查数据库。如何在 PyCharm 中查看数据库的内容,以便可以直观地检查数据库的内容,而不是在控制台中运行查询?
我是一个非常新的PHP语言..目前我正在登录和注册系统.但我不知道为什么用户仍然可以登录到虽然电子邮件和密码插入是错误的,因为我已经做了所有的验证.所以伙计们,请帮助我看看我的代码,看看问题出在哪里.
这是我的代码
<?php
include('config.php');
session_start();
$errors=array();
if ($_SERVER["REQUEST_METHOD"] == "POST"){
$email = $_POST['email'];
$password = $_POST['password'];
if($email&&$password){
//declare variable
$query = mysqli_query($con,"SELECT * FROM user WHERE Email='$email' Password=''$password");
$numrows = mysqli_num_rows($query);
//when user correct input,check the data
if($numrows !== 0) {
while($row=mysqli_fetch_assoc($query)){
$dbemail=$row['Email'];
$dbpassword=$row['Password'];
}
//if username and password match
if($dbemail=$email&&$dbpassword=$password)
{
$SESSION['$email']="$email";
header('Location:user.html');
}
else
{
$errors['notcorrect'] = "Email or password not correct";
}
}
//when insert wrong data
else{
$errors['notexists'] = "This email doesn't exists";
}
}
//when …Run Code Online (Sandbox Code Playgroud) 从数据库中获取数据后,我的结果如下JSON格式:
"return_data": {
"friend_info": [
{
"desc": "name",
"value": "Ken"
},
{
"desc": "profile_pic",
"value": "http://aaa.caa/1234569/picture?type=large"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我想让JSON看起来像:
"return_data": {
"friend_info": [
{
"name": "Ken",
"profile_pic": "http://aaa.caa/1234569/picture?type=large"
}
]
}
Run Code Online (Sandbox Code Playgroud)
但是我完全不知道如何让它像上面的结构一样.有人请让我知道正确的方向,比如我应该使用什么功能等等.谢谢
android ×4
php ×2
retrofit2 ×2
android-architecture-navigation ×1
android-menu ×1
android-xml ×1
audio ×1
front-camera ×1
ios ×1
java ×1
javascript ×1
json ×1
leaflet ×1
mediacodec ×1
mysql ×1
pycharm ×1
python ×1
reactjs ×1
sqlalchemy ×1
sqlite ×1
swift4 ×1
tableview ×1
uistackview ×1